Discussion: regular expression
Afficher un message
Vieux 18/06/2008, 22h05   #1
Petr Dupovnik
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut regular expression

[Note: parts of this message were removed to make it a legal post.]

Hello

Suppose I have a string with some repeating patterns:

string = "some miscellaneous text [sdfsdf.wer], some more miscellaneous text
[vbnfg.thy], and yet more text [jkhjkhjk.345]"

I want catch all instances of "[.*]" in this line - without the square
brackets. - in the above example that would be 'sdfsdf.wer', 'vbnfg.thy',
and 'jkhjkhjk.345'.

What regular expression would pull each instance of "[.*]" into a separate
element in an array?

my_match=string.match('\[(\w+\.\w{3}\]')

This only catches the first match, and ignores the second and third.

grateful for any .

Petr.

  Réponse avec citation
 
Page generated in 0,04217 seconds with 9 queries