Tag Archives: regex
RegEx: Compare two strings to find Alliteration and Assonance
would be possible to Compare two strings to find Alliteration and Assonance?
i use mainly javascript or php
Continue reading
Tagged javascript, php, regex
Leave a comment
Mobile regexp user agent
i have to check in my script for user agent for mobile.
i have
if(preg_match('/lg|iphone|blackberry|opera/i', $_SERVER['HTTP_USER_AGENT'])) { ... }
i found out the lg one needs to be the first part of the string
eg:
lg-9000 ...
lg1000 ...… Continue reading
Tagged mobile, php, regex
Leave a comment
Counting beginning whitespaces
I want to count (within a single regular expression) all spaces at the beginning of a string.
My ideas:
$identSize = preg_match_all("/^( )[^ ]/", $line, $matches);
For example:
$example1 = " Foo"; // should return 1
$example2 = "… Continue reading Recursive PHP Regex
This question is about clarifying the behavior of php’s regex engine for recursive expressions. (If you ideas for how to properly match the strings below without using recursive php regex, that’s very cool, but that’s not the question.)
a(?:(?R)|a?)a
… Continue reading Sanitize sentence in php
The title may sound odd, but im kind of trying to set up this preg_replace that takes care of messy writers for a textarea. It has to:
if there is an exclamation sign, there should not be another one in… Continue reading
Tagged php, preg-replace, regex, sanitization, string
Leave a comment
Get itunes id from url
what is the best way to retrieve id from itunes app link?
let say i have these link:
http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026?mt=8
http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026
i just want to get the id, 457603026 using php preg_match
Continue reading
How to match everything after a character in a URL
Given this URL : http://php.net/manual/en/function.preg-match.php How should i go to select everything after “net” (net not included) and before “.php” (same here not included).
Incoming search terms:php match everything after * Continue reading
php regular expression for video swf
iwant to get the video url from a object/embed html source. i read i can use regular expression to get it but me and regular expression are no friends
so heres what i have:
<?php
function src($text) {
$text =… Continue reading
Tagged php, regex, swf, video
Leave a comment
Why does this regex take so long to find email addresses in certain files?
I have a regular expression that looks for email addresses ( this was taken from another SO post that I can’t find and has been tested on all kinds of email configurations … changing this is not exactly my question… Continue reading
Tagged php, regex, web-scraping
Leave a comment
How to split string to 2D array with Regex?
I’ve got a problem that seems simple on the face of it but has defeated my meager regex skills. I have a string that I need to convert to an array and then process the values accordingly, which is simple… Continue reading
Tagged arrays, php, regex, string
Leave a comment
17 pages
