The original regex matched on 
lower case
  then
uper case
  then
digits
  then
white space
  then
the separator
  then
lower case
  then
uper case
  then
digits
  then
white space

This is not what you wanted.

If '>' is the separator then you should match on:
anything other than the separator
  then
the separator
  then
anything other than the separator

if ( /^([^>]*)>([^>]*)$/ )
{  $string1 = $1;
   $string2 = $2;
}

Also this anchors the match at the beginning and the end of the string so it's 
a more complete solution.

Don




On Saturday 30 October 2004 16:51, [EMAIL PROTECTED] wrote:
> Hi All,
> 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.
>
> I cannot understand what I am missing in the regular expression.
>
> Thanks.


-- 
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