Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Saturday, April 20, 2024

File: [Platon] / scripts / perl / mysql / test-escaped-string-regexp.pl (download)

Revision 1.1, Thu Oct 21 17:40:16 2004 UTC (19 years, 6 months ago) by rajo

test of regexp matching escaped strings

#!/usr/bin/perl

#
# test.pl
#
# Developed by Lubomir Host 'rajo' <rajo AT platon.sk>
# Copyright (c) 2004 Platon SDG, http://platon.sk/
# Licensed under terms of GNU General Public License.
# All rights reserved.
#
# Changelog:
# 2004-10-14 - created
#

# $Platon$

use strict;

$| = 1;
$\ = "\n";

my @strings = (
    qw!
    asdfadf
    1341234E45
    134.1234
    NULL
    null
    ''
    'xxxxxxx'asdfad
    'xx\\xxx'asdfad
    '\\'asdfad
    '\\\\'asdfad
    '\\\\\\'asdfad
    '\\\\\\\\'asdfad
    'xxx\\\\\\'yyyy'asdfad
    'xxx\\\\\\\'yyyy'asdfad
    'xxx\\\\\\\\'yyyy'asdfad
    'xxx\\\\\\\\\'yyyy'asdfad
    !
);

foreach my $str (@strings) {
#while (my $str = <STDIN>) {
    chomp $str;
    # OK: if ($str =~ m/([^']+|'(?:[^'\\]*(?:\\.)*(?:\\\\)*)*')/) {
    if ($str =~ m/([^']+|'(?:[^'\\]|(?:\\.)|(?:\\\\))*')/) {
        print "MATCH  str = \"$str\"\t$1";
    }
    else {
        print "-----  str = \"$str\"";
    }
}

# vim: ts=4
# vim600: fdm=marker fdl=0 fdc=3


Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top