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: /g not working?: Edit Log



alberto_zurita
New User

Sep 8, 2014, 4:08 PM


Views: 3648
/g not working?

I am using the /g modifier to globally match patterns in the following string:

$data_h = "[electronic resource] [electronic resource] [electronic resource] [electronic resource]"



The objective is to delete the extra [electronic resource] patterns and just keep one [electronic resource].

I wrote the following string replacement:

$data_h =~ s/(\[electronic resource\]\s*)+//g;


The current procedure is only deleting the first pattern. So I get the output:

[electronic resource] [electronic resource] [electronic resource]

Only one [electronic resource] got replaced.

What am I doing wrong? Please help.


(This post was edited by alberto_zurita on Sep 8, 2014, 4:09 PM)


Edit Log:
Post edited by alberto_zurita (New User) on Sep 8, 2014, 4:09 PM


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

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