php regular expression to check whether a number consists of 5 digits
how to write a regular expression to check whether a number is consisting only of 5 digits? ...
how to write a regular expression to check whether a number is consisting only of 5 digits? ...
We have lots of referrals from Windows live mail that look like: co114w.col114.mail.live.com by123w.bay123.mail.live.com sn105w.snt105.mail.live.com co101w.col101.mail.live.com and also from Yahoo mail that look like: uk.mg41.mail.yahoo.com us.mg2.mail.yahoo.com us.mc1113.mail.yahoo.com cn.mc150.mail.yahoo.com in.mc84.mail.yahoo.com d...
Is there a better way of doing data validation in Perl than regex? I have Perl code that does string and numeric data validation using complex regex, and this makes code difficult to read and follow, for everyone. ...
Hi. I got a string: "1|2 3 4 oh 5 oh oh|e eewrewr|7|". I want to get the digits between first pipes (|), returning "2 3 4 5". Can anyone help me with the regular expression to do that? ...
My code used to work fine, and now it's breaking. A reduction of the problem is the following: I want to split a source string (from a database, but that's not important) at a separator. The separator is not fixed, but user provided, in a string. I used to do that: @results = split($splitString, $sourceStr); But this breaks when the u...
Greetings! I have some HTML that may or may not be valid. If the HTML is invalid, a best attempt can be made, and any errors that arise are acceptable (ie, grouping too much because some tag isn't closed correctly). In this HTML are a variety of elements, some of which may have a class (call it "findme"). These elements are of varying ...
I have a ruby app parsing a bunch of URLs from strings: @text = "a string with a url http://example.com" @text.split.grep(/http[s]?:\/\/\w/) @text[0] = "http://example.com" This works fine ^^ But sometimes the URLs have text before the HTTP:// for example @text = "What's a spacebar? ...http://example.com" @text[0] = "...http://ex...
I would like to match either any sequence or digits, or the literal: na . I am using: "^\d*|na$" Numbers are being matched, but not na. Whats my mistake? More info: im using this in a regular expression validator for a textbox in aspnet c#. A blank entry is ok. ...
EDIT: OOPS, sorry I wasn't clear. I have a string that I get from AJAX that is an xhtml document, I need to get the body tag of it, unless I can generate a dom tree from the string? I need to get everything from a body tag in a string, including markup, with a javascript regex. I know that this is a duplicate, but the regexes I found i...
if I have, for example, this list of keywords: string keywords = "(shoes|shirt|pants)"; I need to find the whole words in a string. I thought this code would do that: if (Regex.Match(content, keywords + "\\s+", RegexOptions.Singleline | RegexOptions.IgnoreCase).Success) but for some reason it will return true for participants, e...
I have a response: MS1:111980613994 124 MS2:222980613994124 I have the following regex: MS\d:(\d(?:\r?\n?)){15} According to Regex, the "(?:\r?\n?)" part should let it match for the group but exclude it from the capture (so I get a contiguous value from the group). Problem is that for "MS1:xxx" it matches the [CR][LF] and include...
I've been wrestling with an issue I was hoping to solve with regex. Let's say I have a string that can contain any alphanumeric with the possibility of a substring within being surrounded by square brackets. These substrings could appear anywhere in the string like this. There can also be any number of bracket-ed substrings. Examples...
Hi, Vonc, The regular expression which you gave: ^(?:\b\w+\b[\s\r\n]*){1,250}$ to limit 250 words over multiple lines works if it doesn't have any special characters... what should i do if i need to search for number of words which also consists special characters... Some thing like this an example: --> Hi! i need help with regular exp...
I am trying to improve my in-site personal messaging system by making it look nicer and feel more like e-mail. I currently add > before each line of replied text, but I would also like to add formatting such as font color to lines that start with ">" without the quotes. I am not sure how I would close the lines out with a regular expre...
I'm wondering what the regex for an eregi_replace would be needed to catch a string that is not contained in an alt attribute. e.g. It should find and replace John Doe in: "John Doe was born on..." but not find/replace when John Doe's in any tag for example: <img src="/jd.jpg" alt="John Doe at the beach" /> ...
I have a method that was declared like this: public ButtonObject CreateStandardButton(type1 arg1, type2 arg2, ItemClickEventHandler eventHandler, type3 arg3, type4 arg4) ItemClickEventHandler has the usual (sender, e) arguments. However, we never ended up using the (sender, e) arguments, so we have a bunch ...
I have a page that I want to set as a goal in Google Analytics but there is a part of the URL that will be a random numnber (xxxxx). How do I specify such a URL with regex? /products/sf/cart/rf/xxxxx/f/477 ...
I need to improve the method below. The thing is to extract the first folder of an URL if it exists. The urls that can be pass are with domain or without domain, that is to say: http://www.xxx.com/es/test/test.aspx or http://xxx.com/es/test/ or /us/xxx/xxx.aspx. public string ExtractURL(string url) { string result = ""; try ...
Hello, I need to make an statement where the test pass if there is just one asterisk in a string from the source document. Thus, something like <xslt:if test="count(find('\*', @myAttribute)) = 1)> There is one asterisk in myAttribute </xslt:if> I need the functionality for XSLT 1, but answers for XSLT 2 will be appreciated as w...
My main problem is that some output is coming on the page with a space character written as " ". I want to replace it back with a space. I tried str_replace(" "," ",$mystr) and even preg_replace("/( )/", " ", $mystr) but to no avail. How do I do this? And more generally, if there are other html codes coming as output, like ...