Regex question.
Moderators: AArdvark, Ice Cream Jonsey
- pinback
- Posts: 17849
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
Regex question.
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?
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?
Am I a hero? I really can't say. But, yes.
- pinback
- Posts: 17849
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
-
- Posts: 168
- Joined: Mon Sep 09, 2002 4:36 pm
- Location: NJ
perldoc HTML::Parserpinback wrote:I want to strip out all HTML tags from a string EXCEPT for a few specific ones like <i> and <b> and whatnot...
Code: Select all
use HTML::Parser;
$p = HTML::Parser->new( ... );
$p->ignore_tags( @tags );
$p->ignore_elements( @tags );
- pinback
- Posts: 17849
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
- Ice Cream Jonsey
- Posts: 30069
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
- pinback
- Posts: 17849
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
-
- Posts: 2544
- Joined: Tue Jun 04, 2002 10:43 pm
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?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.
Throw us a bone here, or I'll either stop or start throwing a bone to your mom.
Bruce
- pinback
- Posts: 17849
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
-
- Posts: 2544
- Joined: Tue Jun 04, 2002 10:43 pm
Also, then, for some other language, you want to look for the PCRE library. PCRE being "Perl-Compatible Regular Expressions."bruce wrote:Then why did you muddy the waters by asking for a solution if you weren't using Perl?pinback wrote:Perl.
Then you can, after some initialization, plug your Perl regexps into quite a number of languages.
Bruce
- pinback
- Posts: 17849
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
- pinback
- Posts: 17849
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
-
- Posts: 168
- Joined: Mon Sep 09, 2002 4:36 pm
- Location: NJ
You mean this one?pinback wrote:can you answer my original question?
Of course.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...
- pinback
- Posts: 17849
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
-
- Posts: 168
- Joined: Mon Sep 09, 2002 4:36 pm
- Location: NJ
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.
- pinback
- Posts: 17849
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact: