Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Nedeľa, 21. júl 2024

Súbor: [Platon] / scripts / perl / mysql / test-escaped-string-regexp.pl (stiahnutie)

Revízia 1.1, Thu Oct 21 17:40:16 2004 UTC (19 years, 9 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.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok