Re: Help with a Regular Expression



Mr.Steskal wrote on 11 jul 2007 in comp.lang.javascript:

Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression
Help

-----------------------------------------------------------------------
---------

I need help writing a regular expression that only returns part of a
string.

For Example I have a multi-line text fragment like below:

PC ADVISORS, LC
1234 MT. PARMA ROAD. SUITE A1
ATLANTA, GA 30097
PH. (404) 555-1212

I write a regular express that retrieves the second line. I want to
only return all the data before SUITE A1 in the line. The regular
expression I have so far is "\n\n.*?! S" . This returns "1234 MT.
PARMA ROAD. S" . Could anybody help me figure out how to write a
regular expression that only returns "1234 MT. PARMA ROAD." . The
stipulation is that the first part of the line is a variable length.

<script type='text/javascript'>

var t = 'PC ADVISORS, LC\n1234 MT. PARMA ROAD. SUITE A1\n'+
'ATLANTA, GA 30097\nPH. (404) 555-1212'

t = t.replace(/(^.*?\n)|( suite[\s\S]*)/ig,'')

alert(t)

</script>



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
.



Relevant Pages

  • Help with a Regular Expression
    ... 2007 7:01 am Post subject: Regular Expression ... string. ... PARMA ROAD. ... only return all the data before SUITE A1 in the line. ...
    (comp.lang.javascript)
  • Re: Help with a Regular Expression
    ... I need help writing a regular expression that only returns part of a ... PARMA ROAD. ... only return all the data before SUITE A1 in the line. ... regular expression that only returns "1234 MT. ...
    (comp.lang.javascript)
  • Regular Expression Help
    ... I need help writing a regular expression that only returns part of a ... PARMA ROAD. ... only return all the data before SUITE A1 in the line. ... regular expression that only returns "1234 MT. ...
    (microsoft.public.dotnet.languages.vb)