Phone number validation in PHP
I need to validate phone number in PHP. I have made following regex, but I also need to it to accept numbers starting with plus char, how can I do that? ^[0-9]$ ...
I need to validate phone number in PHP. I have made following regex, but I also need to it to accept numbers starting with plus char, how can I do that? ^[0-9]$ ...
Consider it that '_'s in a number doesn't change that number's value so 1000==1_000==10_00. The Problem: given numbers like 1_244_23 1412_2 1_1111 etc..., how could I decide whether certain number appears in that collection? For example: 1244_23 yes, 11_111 yes, 1412_1 no. How could using regex to solve this? I mean, if I could tell th...
I need to convert a Perl script to VB.NET. I have managed almost the entire conversion, but some Perl (seemingly simple) regex are causing an headache. Can someone suggest me .NET equivalent of the following perl regex: 1) $letter =~ s/Users //,; $letter =~ s/Mailboxes //,; if($letter =~ m/$first_char/i){ 2) unless($storegroup =~ /...
Using Core Data w/a sqlite store on iPhone.... I've got a bunch of comic book image entities, each with a string that includes the comic's issue#, e.g.: image.imageTitle = @"Issue 12: Special Edition"; Part of the UI allows the user to type in an issue number to jump to the next issue. My initial code for this was sloooooooow because im...
Suppose you have a string: "SELECT * FROM TABLE WHERE column1 = :var1 AND column2 = :var2" Now, how do I get an array with all the variables like so: Array ( [0] => :var1 [1] => :var2 ) I've tried it with PHP's preg_match_all, but I struggle with the regex. $varcount = preg_match_all("/ :.+ /", $sql, $out); ...
I want to transform a line that looks like this: any text #any text# ===#text#text#text#===# into: any text #any text# ===#texttexttext===# As you can see above I want to remove the # between ===# and ===# The number of # that are supposed to be removed can be any number. Can I do this with sed? ...
In C# what's the best way to remove blank lines i.e., lines that contain only whitespace from a string? I'm happy to use a Regex if that's the best solution. EDIT: I should add I'm using .NET 2.0. ...
Hi all. Got some trouble with my preg_match. The code. $text = "tel: 012 213 123. mobil: 0303 11234 \n address: street 14"; $regex_string = '/(tel|Tel|TEL)[\s|:]+(.+)[\.|\n]/'; preg_match($regex_string , $text, $match); And I get this result in $match[2] "012 213 123. mobil: 023 123 123" First question. I want the regex to stop at...
I need to use php to add a space between a period and the next word/letter when there's none. For example, "This is a sentence.This is the next one." needs to become "This is a sentence. This is the next one." Notice the added space after the first period. My problem is that even if I'm able to make a regular expression that finds ever...
I'm having trouble coming up with a regular expression to match a particular case. I have a list of tv shows in about 4 formats: Name.Of.Show.S01E01 Name.Of.Show.0101 Name.Of.Show.01x01 Name.Of.Show.101 What I want to match is the show name. My main problem is that my regex matches the name of the show with a preceding '.'. My reg...
I'm looking to validate the length of a textarea using a regular expression validator. It should allow all characters and crlfs. I'm also concerned about crlfs counting as 1 or 2 characters, I'm concerned it may be different across browsers but I'm hoping ASP.NET regulates it. Also, I'm saving to a mix of varchar and nvarchar fields in M...
I need to find « in a string with a regex. How would you add that into the following: String RegExPattern = @"^[0-9a-df-su-z]+\.\s«"; Regex PatternRegex = new Regex(RegExPattern); return (PatternRegex.Match(Source).Value); ...
Hi, I have something like this: $arr[] = 'Seto Hakashima' $arr[] = 'Anna (segment "Yvan Attal") (as Robin Wright Penn)' $arr[] = 'Sara (segment "Yvan Attal")' I need to remove the the second couple of parenthesis (only when there is a second couple), and get this: $arr[] = 'Seto Hakashima' $arr[] = 'Anna (segment "Yvan Attal")' $arr[...
Why does the second statement fail? works Regex.Replace("zz WHERE zz", "where", "yy", RegexOptions.IgnoreCase | RegexOptions.Singleline); does not Regex.Replace("zz WHERE zz", "\bwhere\b", "yy", RegexOptions.IgnoreCase | RegexOptions.Singleline); This works to but replaces the space which i do not want to do Regex.Replace("zz WHE...
I'm not that good with regular expressions... I need a JavaScript regular expression that will do the following: The string can contain letters (upper and lower case), but not punctuations such as éàïç... The string can contain numbers (0..9) anywhere in the string, except on the first position. The string can contain underscores (_)....
I'm rubbish at Regular Expressions, really! What I'd like is to split a string containing a CSS property value into an array of [string,value,unit]. For example: if I supplied the .split() method with 1px it'd return ["1px",1,"px"]. If I were to supply, similarly, 10% it'd return ["10%",10,"%"]. Can this be done? I appreciate all you...
Hi. I'm currently developing a little browser-based Twitter widget. Currently, I'm stuck with getting the URLs to work. I'm kinda newbie, when it comes to regex (I know, how to get parts of a string, but this one – tough one). So, I need a regex that would search/replace www.domain.tld -> <a href="http://www.domain.tld">http://www....
I'm trying to use javascript to find all URLs in a textarea as the person is typing (onkeyup). The problem that I'm having is in finding a regex to match the entire URL, I need it only to match all the URL's in the text area that are complete URLs. All of the existing regex expressions that I find through Google and through my own exper...
I have a string of text that contains html with all different types of links (relative, absolute, root-relative). I need a regex that can be executed by PHP's preg_replace to replace all relative links with root-relative links, without touching any of the other links. I have the root path already. Replaced links: <tag ... href="path/to...
I'm developing a syntax analyzer by hand in Java, and I'd like to use regex's to parse the various token types. The problem is that I'd also like to be able to accurately report the current line number, if the input doesn't conform to the syntax. Long story short, I've run into a problem when I try to actually match a newline with the S...