Page 1 of 1
Regex question.
Posted: Mon May 02, 2005 2:45 pm
by pinback
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?
Posted: Mon May 02, 2005 2:56 pm
by pinback
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.
Posted: Mon May 02, 2005 3:39 pm
by k. roo
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::Parser;
$p = HTML::Parser->new( ... );
$p->ignore_tags( @tags );
$p->ignore_elements( @tags );
Posted: Mon May 02, 2005 3:41 pm
by pinback
Okay, that's awesome. Now, how about if, say, I'm not using Perl?
Posted: Mon May 02, 2005 3:43 pm
by Ice Cream Jonsey
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.
Posted: Mon May 02, 2005 7:38 pm
by pinback
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.
Posted: Mon May 02, 2005 8:41 pm
by bruce
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
Posted: Tue May 03, 2005 6:35 am
by pinback
Perl.
Posted: Tue May 03, 2005 11:28 am
by bruce
pinback wrote:Perl.
Then why did you muddy the waters by asking for a solution if you weren't using Perl?
Bruce
Posted: Tue May 03, 2005 11:30 am
by bruce
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
Posted: Tue May 03, 2005 12:18 pm
by pinback
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.
Posted: Tue May 03, 2005 12:19 pm
by pinback
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?
Posted: Tue May 03, 2005 1:31 pm
by k. roo
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.
Posted: Tue May 03, 2005 2:22 pm
by pinback
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.
Posted: Tue May 03, 2005 2:38 pm
by k. roo
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.
Posted: Tue May 03, 2005 3:13 pm
by pinback
Ah. See, that's helpful now. Now you're helping.
Posted: Wed May 04, 2005 7:51 am
by Guest
if you smell a spindle of fresh "Verbatim" CD-Rs for long enough, so that you get a little high, it smells like marzipan.
Posted: Wed May 11, 2005 10:04 am
by Lysander
I always thought my CDRs smelled like roses. It weirded me out.