Jump to content

Need help with StringRegExpReplace


Recommended Posts

I'm looking for assistance in finding correct RegExp syntiax.

I need to strip out html code from a string like the following:

CODE
<tr><td align=right nowrap>&-nbsp 16 Apr 2007 </td>

Leaving only the date 16 Apr 2007

The below code work fine stripping out everything except the &-nbsp. How to do this ?

CODE
$input="<tr><td align=right nowrap> &-nbsp 15 Apr 2007 </td>"

$output = StringRegExpReplace($input, '(?s)(?i)\<[^\>]*\>', '')

MsgBox(0,"Result",$output)

Note: The real word to remove is &-nbsp without the - , Posting without - clear the code

Thanking in advance for any help

Edited by MarioX
Link to comment
Share on other sites

I'm looking for assistance in finding correct RegExp syntiax.

I need to strip out html code form a string like the following:

<tr><td align=right nowrap> 15 Apr 2007 </td>

The below code work fine leaving the date 15 Apr 2007 but it don't get rid of '&nbsp;' . How to do this ?

CODE
$input="<tr><td align=right nowrap> 15 Apr 2007 </td>"

$output = StringRegExpReplace($input, '(?s)(?i)\<[^\>]*\>', '')

MsgBox(0,"Result",$output)

Thanking in advance for any help
um... where is the &nbsp;? I know what it is and all... I just can't see it :shocked: Other than that it worked fine :(
Link to comment
Share on other sites

um... where is the &nbsp;? I know what it is and all... I just can't see it :shocked: Other than that it worked fine :(

I agree, when I post the message, my code is formatted and the &-nbsp (without -) is cleared...

Link to comment
Share on other sites

Link to comment
Share on other sites

The string to clean is the following:

<tr><td align=right nowrap>&nbsp 16 Apr 2007 </td>

Thanks again for help!

Um not really sure on StringRegExpReplace, but string replace should do the trick:

This worked well:

$input="<tr><td align=right nowrap>&nbsp 16 Apr 2007 </td>"
$output = StringRegExpReplace($input, '(?s)(?i)\<[^\>]*\>', '')
$output = StringReplace ($output, "&nbsp", "")
MsgBox(0,"Result",$output)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...