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: Regular Expressions:
how to deal with it?

 



libo
Novice

Aug 12, 2002, 12:07 PM

Post #1 of 5 (4230 views)
how to deal with it? Can't Post

I need to delete "option B" from $string1,like the result in $string2. How to do it by regular expression? Thanks.

$string1 = "<option value=A>AAA</option><option value=B>BBB</option><option value=C>CCC</option>";

$string2 = "<option value=A>AAA</option><option value=C>CCC</option>";


Paul
Enthusiast

Aug 12, 2002, 12:47 PM

Post #2 of 5 (4229 views)
Re: [libo] how to deal with it? [In reply to] Can't Post


Code
$string1 = "<option value=A>AAA</option><option value=B>BBB</option><option value=C>CCC</option>";  

$string1 =~ s|<option value=B>BBB</option>||i;


The basic method :)


libo
Novice

Aug 12, 2002, 12:55 PM

Post #3 of 5 (4227 views)
Re: [RedRum] how to deal with it? [In reply to] Can't Post

Thanks, but what if B standing for a string that is various in <option value=B>BBB</option>


Paul
Enthusiast

Aug 12, 2002, 1:01 PM

Post #4 of 5 (4226 views)
Re: [libo] how to deal with it? [In reply to] Can't Post

Sorry I'm not sure what you mean.


libo
Novice

Aug 12, 2002, 1:15 PM

Post #5 of 5 (4224 views)
Re: [RedRum] how to deal with it? [In reply to] Can't Post

Let me explain more abou this problem:

$string1 = "<option value=A>AAA</option><option value=B>BBB</option><option value=C>CCC</option>";

$stirng1 is result obtained from a function. "AAA", "BBB", "CCC" are dynamically created by the function. Thus we don't know what are "AAA", "BBB", "CCC" before doing regualar expression. For example:

For the first time, we get: <option>...</option><option value=location1>new york</option><option value=location2>chicago</option><option value=location3>houston</option><option>...</option>

For the second time, we get: <option>...</option><option value=location1>boston</option><option value=location2>denver</option><option value=location3>houston</option><option>...</option>

how to always delete <option value=location2>XXX</option> from the string.

 
 


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

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