Mutliple matches

19 views
Skip to first unread message

pip7...@gmail.com

unread,
May 8, 2015, 10:38:52 AM5/8/15
to re...@googlegroups.com
Hello

I'm using Ruby with regular expression to try and return multiple matches.
eg - from "myarray1 =  myarray[1234] and myarray2 = myarray[5678910]" I want to return
myarray[1234] myarray[5678910] .. with my code below I'm only returning the first one eg myarray[1234]

puts /myarray\[\d+\]/.match("myarray1 =  myarray[1234] and myarray2 = myarray[5678910]")

any help much appreictaed.

Regards

Prashant Patole

unread,
May 9, 2015, 8:28:49 AM5/9/15
to re...@googlegroups.com
i am a .Net guy hence dont know much about Ruby syntax and methods.

however can help with respect to regex functionality


I think you insted of finding what you want... you must take up strategy that will remove what you dont want.

was able to achieve by this result

find string is

(?:[\w ]+)[ ]+=[ ]

and replace string is blank... send a empty string to replace parameter like ""
(cant put it in Ruby syntax sorry)

--
--
Sub, Unsub, Read-on-the-web, tune your personal settings for this Regex forum:
http://groups.google.com/group/regex?hl=en

---
You received this message because you are subscribed to the Google Groups "Regex" group.
To unsubscribe from this group and stop receiving emails from it, send an email to regex+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages