Regexp assignment

I have a string that I want to seperate individual parts; for example
in the below string I want the 196 and 21.

I can do this using sub and then modifying the strings. Is there
anyway to do this simply and easily?

Something like : ([0-9]+,’[0-9]+’)

An array would be O.K.

···

Kurt

There is no good and evil; there is only power.

string = “javascript:clist(196,‘21’)”
m = /((\d+),‘(\d+)’)/.match(string)
m[1] #=> 196
m[2] #=> 21

···

On Thursday, 8 May 2003 at 12:02:11 +0900, Kurt V. Hindenburg wrote:

I have a string that I want to seperate individual parts; for example
in the below string I want the 196 and 21.

I can do this using sub and then modifying the strings. Is there
anyway to do this simply and easily?

Something like : ([0-9]+,‘[0-9]+’)


Jim Freeze

Every four seconds a woman has a baby. Our problem is to find this
woman and stop her.

Well, for this particular example, the following would work…

“<a href="javascript:clist(196,‘21’)">”.scan /\d+/
#=> [196,21]

For anything more complex, however, it would be a custom job.

···

On Thu, May 08, 2003 at 12:02:11PM +0900, Kurt V. Hindenburg wrote:

I have a string that I want to seperate individual parts; for example
in the below string I want the 196 and 21.

I can do this using sub and then modifying the strings. Is there
anyway to do this simply and easily?

Something like : ([0-9]+,‘[0-9]+’)

An array would be O.K.


Bruce Williams -
bruce@codedbliss.com - http://codedbliss.com