Jump to content

Recommended Posts

Posted (edited)

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
Posted

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 :(
Posted

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...

Posted
Posted

Ahh... ok :shocked: so i ad the at the end before </td>>>

The string to clean is the following:

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

Thanks again for help!

Posted

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)
Posted

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)
It work, thanks for the suggestion!

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
×
×
  • Create New...