| | |
regex
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 70
Reputation:
Solved Threads: 1
anyone can help me to make regular expression
[code ]
$string="
xxxxx
xxxxx
<body border='0'>
<script language=javascript>
...
word1 ... word2 ... word3... word4
...
</script>
";
i want to remove all word from that string if that string have minimal three word'x'
preg_replace(); how to make that regex?
[code ]
$string="
xxxxx
xxxxx
<body border='0'>
<script language=javascript>
...
word1 ... word2 ... word3... word4
...
</script>
";
i want to remove all word from that string if that string have minimal three word'x'
preg_replace(); how to make that regex?
http://www.duniaislam.site50.net
Others Social Bookmarking http://www.bisnis-indonesia.org
Business Web Directory
http://www.bisnis-indonesia.biz
Others Social Bookmarking http://www.bisnis-indonesia.org
Business Web Directory
http://www.bisnis-indonesia.biz
•
•
Join Date: Mar 2008
Posts: 70
Reputation:
Solved Threads: 1
yes remove all if get same pattern.. the problem is how to make regex pattern...
http://www.duniaislam.site50.net
Others Social Bookmarking http://www.bisnis-indonesia.org
Business Web Directory
http://www.bisnis-indonesia.biz
Others Social Bookmarking http://www.bisnis-indonesia.org
Business Web Directory
http://www.bisnis-indonesia.biz
php Syntax (Toggle Plain Text)
$pattern = "/x{3}/"; $string = preg_replace($pattern,'', $string);
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Mar 2008
Posts: 70
Reputation:
Solved Threads: 1
not like that.. iwant to remove all from <script> tag till </script> if match with the pattern..
the pattern from
<script .....>
... targetword1..
... targetword2..
... targetword3..
</script>
the pattern from
<script .....>
... targetword1..
... targetword2..
... targetword3..
</script>
http://www.duniaislam.site50.net
Others Social Bookmarking http://www.bisnis-indonesia.org
Business Web Directory
http://www.bisnis-indonesia.biz
Others Social Bookmarking http://www.bisnis-indonesia.org
Business Web Directory
http://www.bisnis-indonesia.biz
•
•
Join Date: Feb 2009
Posts: 4
Reputation:
Solved Threads: 0
If you want to see if there are 3 or more x's, use:
The {3} means looking for 3 of the preceding character but {3,} means 3 or more. There's a great tutorial on regex in PHP here: http://www.sitepoint.com/article/reg...pressions-php/
PHP Syntax (Toggle Plain Text)
$pattern = "/x{3,}/"
The {3} means looking for 3 of the preceding character but {3,} means 3 or more. There's a great tutorial on regex in PHP here: http://www.sitepoint.com/article/reg...pressions-php/
This isn't the best solution (Infact, its kinda sloppy!). First, use preg_match to search for pattern "xxx". If found, then, use preg_match again, but this time, search for pattern, '/<script[^>]+\>(.*)<\/script>/s' . This will again return the string between <script> tags. Then use str_replace and replace the matched string with "".
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- Matching multiple href="Something.aspx" using RegEx (ASP.NET)
- regex question (Perl)
- regex (boost) (C++)
- Getting the start / end of string in regex through match objects (Python)
- Regex in Java (Java)
- Regex for password (Shell Scripting)
- Regex in C++ (C++)
- help with regex...and marking up text in JTextpane with html (Java)
Other Threads in the PHP Forum
- Previous Thread: nl2br question
- Next Thread: stopping the script
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail menu mlm mod_rewrite multiple mysql number oop parse paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space sql structure subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web websphere xml youtube






