Regex question.

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:smile: :sad: :eek: :shock: :cool: :-x :razz: :oops: :evil: :twisted: :wink: :idea: :arrow: :neutral: :mrgreen:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Regex question.

by Lysander » Wed May 11, 2005 10:04 am

I always thought my CDRs smelled like roses. It weirded me out.

by Guest » Wed May 04, 2005 7:51 am

if you smell a spindle of fresh "Verbatim" CD-Rs for long enough, so that you get a little high, it smells like marzipan.

by pinback » Tue May 03, 2005 3:13 pm

Ah. See, that's helpful now. Now you're helping.

by k. roo » Tue May 03, 2005 2:38 pm

Code: Select all

strip_tags

(PHP 3>= 3.0.8, PHP 4 , PHP 5)
strip_tags -- Strip HTML and PHP tags from a string
Description
string strip_tags ( string str [, string allowable_tags] )

This function tries to return a string with all HTML and PHP tags stripped from a given str. It uses the same tag stripping state machine as the fgetss() function.

You can use the optional second parameter to specify tags which should not be stripped. 

Code: Select all

You can use the optional second parameter to specify tags which should not be stripped. 

Code: Select all

optional second parameter specify tags should not be stripped. 

Code: Select all

should not be stripped. 

Code: Select all

stripped. 

by pinback » Tue May 03, 2005 2:22 pm

None of those threads answers the question. I know how to strip out tags I don't want. I wanted to do it the other way, strip out everything BUT the ones that I DO want.

I rate all of your helpfulnesses in this thread a minus a million out of 10 so far.

by k. roo » Tue May 03, 2005 1:31 pm

pinback wrote:can you answer my original question?
You mean this one?
pinback wrote:I want to strip out all HTML tags from a string EXCEPT for a few specific ones like <i> and <b> and whatnot...
Of course.

by pinback » Tue May 03, 2005 12:19 pm

bruce wrote: Then you can, after some initialization, plug your Perl regexps into quite a number of languages.

Bruce
Okay. Now, with that all established, can you answer my original question?

by pinback » Tue May 03, 2005 12:18 pm

bruce wrote:
pinback wrote:Perl.
Then why did you muddy the waters by asking for a solution if you weren't using Perl?

Bruce
I'm not using Perl. I'm using PHP. Which provides Perl regex functions.

by bruce » Tue May 03, 2005 11:30 am

bruce wrote:
pinback wrote:Perl.
Then why did you muddy the waters by asking for a solution if you weren't using Perl?
Also, then, for some other language, you want to look for the PCRE library. PCRE being "Perl-Compatible Regular Expressions."

Then you can, after some initialization, plug your Perl regexps into quite a number of languages.

Bruce

by bruce » Tue May 03, 2005 11:28 am

pinback wrote:Perl.
Then why did you muddy the waters by asking for a solution if you weren't using Perl?

Bruce

by pinback » Tue May 03, 2005 6:35 am

Perl.

by bruce » Mon May 02, 2005 8:41 pm

pinback wrote:
Ice Cream Jonsey wrote:You never specified what you were using.

It's regex. It's a common syntax. If you're not part of the solution, you're part of the problem.
Which fucking regex? Shell regular expressions are not Perl regular expressions. Java's got classes for both of 'em I think. GNU Extended Regular Expressions?

Throw us a bone here, or I'll either stop or start throwing a bone to your mom.

Bruce

by pinback » Mon May 02, 2005 7:38 pm

Ice Cream Jonsey wrote:You never specified what you were using.

It's regex. It's a common syntax. If you're not part of the solution, you're part of the problem.

by Ice Cream Jonsey » Mon May 02, 2005 3:43 pm

pinback wrote:Okay, that's awesome. Now, how about if, say, I'm not using Perl?
You never specified what you were using. Here, let me help -- let me tell you about FIND and REPLACE in a text editor.

by pinback » Mon May 02, 2005 3:41 pm

Okay, that's awesome. Now, how about if, say, I'm not using Perl?

by k. roo » Mon May 02, 2005 3:39 pm

pinback wrote:I want to strip out all HTML tags from a string EXCEPT for a few specific ones like <i> and <b> and whatnot...
perldoc HTML::Parser

Code: Select all

use HTML&#58;&#58;Parser;
$p = HTML&#58;&#58;Parser->new&#40; ... &#41;;
$p->ignore_tags&#40; @tags &#41;;
$p->ignore_elements&#40; @tags &#41;;

by pinback » Mon May 02, 2005 2:56 pm

Or, I'll ask even more directly:

I want to strip out all HTML tags from a string EXCEPT for a few specific ones like <i> and <b> and whatnot...

How how how.

Regex question.

by pinback » Mon May 02, 2005 2:45 pm

Why can't I figure this out...

I want to do WORD negation, instead of just character negation...

For instance, let's say I want to match any name which ISN'T "Ben", "Robb", or "Porkball"... something like...

/[^(Ben|Robb|Porkball)]/

...which doesn't work of course, but how do you do it?

Top