Home General Computer Multimedia Business Lounge
|
Ask Regex help
|
|
12-14-2011, 11:13 PM
|
|||
|
|||
|
guys ,
what is the compatible regex to find link like this ... http://yoursite.com/site/news.php?gid=10 http://yoursite.com/site/news.php?gid=2 https://yoursite.com/site/news.php?gid= |
|||
|
12-15-2011, 01:41 AM
(This post was last modified: 12-15-2011 01:43 AM by ketek.)
|
|||
|
|||
|
RE: Regex help
if you want to just find links like that, test it with this one
Code: https?\:\/\/([a-zA-Z0-9]*\.)+[a-zA-Z0-9]+(\/[^\/?]*)+\?[^\s]* |
|||
|
12-16-2011, 08:38 PM
(This post was last modified: 12-16-2011 08:39 PM by darkslayer.)
|
|||
|
|||
RE: Regex help
(12-15-2011 01:41 AM)ketek Wrote: if you want to just find links like that, test it with this one PHP Code: <?phpCode: http://yoursite.com/site/news.php?gid=10 >> FALSEcant u tell me why no 1 output is FALSE? |
|||
|
12-17-2011, 06:43 PM
(This post was last modified: 12-17-2011 07:02 PM by ditatompel.)
|
|||
|
|||
RE: Regex help
(12-16-2011 08:38 PM)darkslayer Wrote: Wrong regex on preg_match PHP Code: if(preg_match("/http:\/\/yoursite.com\/site\/news.php?gid=10/",$x)){echo "$x >> TRUE<br>";}else{echo "$x >> FALSE<br>";} Code: * + ? . ( ) [ ] { } / | ^ $Unlike C# or Java, PHP does not require all backslashes in strings to be escaped. If you want to include a backslash as a literal character in a PHP string, you only need to escape it if it is followed by another character that needs to be escaped. if you want to ouse Ketek pregmatch it should be like this : PHP Code: if(preg_match("/https?\:\/\/([a-zA-Z0-9]*\.)+[a-zA-Z0-9]+(\/[^\/?]*)+\?[^\s]*/i",$x)) { |
|||
|
12-17-2011, 08:46 PM
(This post was last modified: 12-17-2011 08:47 PM by darkslayer.)
|
|||
|
|||
RE: Regex help
(12-17-2011 06:43 PM)ditatompel Wrote: The characters that you SHOULD escape are:ouch.. thanx bro Quote:if(preg_match("/http:\/\/yoursite.com\/site\/news.php\?gid=10/",$x)){echo "$x >> TRUE<br>";}else{echo "$x >> FALSE<br>";}i dont know if (?) or non-alphanumeric it must be escaped. thanx back to topic i dont know what kalakhan's example mean if he mean like this PHP Code: asdasdasbut if he mean like this PHP Code: http://rftk.com/swdfghjkl/defrgtyhujkl.php?sdtfyh=10PHP Code: "/[(http)|(https)]:\/\/yoursite.com\/site\/news.php\?gid=[0-9]?/" |
|||
|
« Next Oldest | Next Newest »
|
| Topic Tools | ||||||
| ||||||
| Possibly Related Threads... | |||||
| Thread: | Author | Replies: | Views: | Last Post | |
| [Tutor] [share]Pengenalan Dasar-Dasar Regex | RieqyNS13 | 15 | 244 |
05-02-2013 09:24 PM Last Post: CodeSearcher |
|
| [Solved] [solved]regex with multiple line | darkslayer | 0 | 348 |
10-14-2011 08:06 PM Last Post: darkslayer |
|
| Users Browsing |
| 1 Guest(s) |











