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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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


Mar 1, 2002, 3:15 AM

Views: 8120
Re: [aksagar] Split Function

Using ( ) stores the match in the special numerical scalar, $1, $2 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


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