View Full Version : about regular expressions


nacho
01-08-2006, 04:40 PM
I would like to know how can I represent a string with any character except the string "<b>" and including the substring "Nacho", for example.
I mean:
"Hi!, my name is Nacho", this will give "ok".
But, "Hi!, my name is <b>Nacho</b>", this wouldn't give "ok".

I know that something like [^0-9] will find any string without numbers, but something more complicated, I don't know how. The example would be something like
(.*[^<b>]Nacho)+
but I guess it's not correct.

Wow, I don't know if the question is clear.
Thanks a lot, and really congrats for this wonderful site.

BSolveIT
01-08-2006, 05:47 PM
I don't for sure what your ultimate goal is, but here's a bit of ASP I use to strip out any HTML:

<%
function stripHTML(content)
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>"
RegEx.Global = True
stripHTML = RegEx.Replace(content, "")
end function
%>

This maybe is nothing to do with what your aiming for, but in the off chance that it helps...?

----- Sorry, I posted my reply by looking at new posts, didn't notice until it was too late this is the PHP forum. Sorry again.

ERE Breckenridge
01-29-2006, 07:58 PM
If your main purpose is to strip html tags use:

tring strip_tags ( string str [, string allowable_tags] )