CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [aksagar] Split Function: Edit Log



Paul
Enthusiast

Mar 1, 2002, 3:15 AM


Views: 3350
Re: [aksagar] Split Function

Using ( ) stores the match in the special numerical scalar, $1, $2 etc...so you could do:

$_ = 'Hello my name is Joe Bloggs';
/^(\w+)\s(\w+)/ and ($hello,$my) = ($1,$2);

[ ] are used for character classes. ie they match a range of characters eg... [a-z0-9] they also disable meta-characters. Putting a ^ at the beginning tells the regex not to match any of the characters....eg

/^[^a-z]+$/

....will match a string that doesn't have a,b,c,d,e....z


(This post was edited by RedRum on Mar 1, 2002, 3:16 AM)


Edit Log:
Post edited by Paul (Enthusiast) on Mar 1, 2002, 3:15 AM
Post edited by Paul (Enthusiast) on Mar 1, 2002, 3:16 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives