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:
reg express question

 



menchen
User

Mar 6, 2001, 8:45 PM

Post #1 of 3 (174 views)
reg express question Can't Post

say i have a string like the following:

$string = 'sxuy asdf 2143 asdf <id>jason</id>dfasdf asf safsa <id>john</id> asdlfj sf safd sdf <id>joe</id>';

question now is how do i get all the ids from that string and put them into an array?
all ids are between <id> and </id>

thanks for your help.

-jason




Jean
User


Mar 7, 2001, 2:21 AM

Post #2 of 3 (172 views)
Re: reg express question [In reply to] Can't Post

This should help you.
Of course inside the loop you will do something other than print Smile


Code
$string = 'sxuy asdf 2143 asdf <id>jason</id>dfasdf asf safsa <id>john</id> asdlfj sf safd sdf <id>joe</id>'; 
while ( $string =~ /<id>(.+?)<\/id>/ig ) {
print "$1\n";
}

Jean Spector
QA Engineer @ Extent Technologies, Ltd.
mage@lycosmail.com


menchen
User

Mar 7, 2001, 3:56 PM

Post #3 of 3 (166 views)
Re: reg express question [In reply to] Can't Post

thank you very much jean :)

-jason


 
 


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

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