[EMAIL PROTECTED] wrote:
I have to match patterns of the format
string1>string2
where the strings 1 & 2 can contain alphabets,numbers and spaces. The
string are separated by '>' sign. I wrote the following code for this.

if(/([a-z]*[A-Z]*[0-9]*[\s]*)>([a-z]*[A-Z]*[\s]*[0-9]*)/g) {
    $string1 = $1;
    $string2 = $2;
}

This picks up only the first character in string 2 whereas I want
everything till the end of the $_ to be in the string. $_ is terminated
by \n.

You should provide sample data to make it easier to help you!

Anyway, the regex above seems to not match your verbal description. Can it possibly be that string 2 begins with a digit followed by some other type of character?

You seem to want something like:

    /([a-z0-9\t ]*)>([a-z0-9\t ]*)/gi

Putting everything in the same character class allows the characters to appear in any order, unlike in your regex above. I also dropped \s, since newline is included in that class, and replaced it with a \t and a space.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to