Sign in to follow this  
Followers 0
MarioX

Need help with StringRegExpReplace

7 posts in this topic

#1 ·  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

Share this post


Link to post
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 :(

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
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
Sign in to follow this  
Followers 0