Re: pattern matching

From: John W. Krahn (krahnj_at_telus.net)
Date: 10/31/04


Date: Sat, 30 Oct 2004 18:52:11 -0700
To: Perl Beginners <beginners@perl.org>

mk76@buffalo.edu wrote:
> Hi All,

Hello,

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

my ( $string1, $string2 ) = /^([[:alnum:][:blank:]]*)>([[:alnum:][:blank:]]*)$/

John

-- 
use Perl;
program
fulfillment


Relevant Pages

  • Re: LPCWSTR to CString conversion problem
    ... I get the first character of the string and pass it to ... LPCWSTR to CString conversion. ... Do you compile as Unicode or Ansi? ... GetAtreturns the second character of the string, ...
    (microsoft.public.vc.atl)
  • Re: perl question
    ... > string I am using in a pattern command. ... > Ideally I'd like to see if the first character is a zero, ... Perl is ideal for that sort of thing. ... O'Reilly Perl books would be a good choice. ...
    (comp.os.vms)
  • Re: Converting Type Characters to type string
    ... used to determine whether or not the input was a integer roman numeral ... advice and are using Get_Line to read an entire string first, ... look at the first character of the string to see whether it's Q or a ... can still convert the entire input string using Integer'Value. ...
    (comp.lang.ada)
  • Re: Capitalizing the first letter
    ... Education Technology Department Ankara / TURKEY ... In PHP ucfirstfunction make a string's first character uppercase. ... But ralph smith have two words respectivetely ralph and smith. ... string, ...
    (php.general)
  • Re: Capitalizing the first letter
    ... Education Technology Department Ankara / TURKEY ... In PHP ucfirstfunction make a string's first character uppercase. ... But ralph smith have two words respectivetely ralph and smith. ... string, ...
    (php.general)