Hassan Schroeder
8/13/2008 2:23:00 PM
On Wed, Aug 13, 2008 at 7:10 AM, Gunther Gunt
<gunther.thevenin@airbus.com> wrote:
> I am trying to create a regular expression with the following rule:
>
> my text is:
> <TEXT id=''>blabla</TEXT>
> I want to replace <TEXT*> with something
>
> "<TEXT id=''>".gsub(/the magic regular expression/,"replacement")
> ==> replacementblabla</TEXT>
This example isn't consistent with the following ones -- do you
want the ending </TEXT> inserted even if it's not in the original
string?
> but i want also that
> "<TEXT>blabla</TEXT>".gsub(/the magic regular expression/,"replacement")
> returns the same result
> ==> replacementblabla</TEXT>
>
> and
> <TEXT *anything*>blabla</TEXT>".gsub(/the magic regular
> expression/,"replacement")
> returns the same result
> ==> replacementblabla</TEXT>
Assuming the second two are actually what you want, try
"<TEXT id='foo'>blabla</TEXT>".gsub(/<TEXT[^>]*>/, 'replacement')
HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com