Regex: How to match a string that is not only numbers?

(?! ^\d+$)^. +$ This says lookahead for lines that do not contain all digits and match the entire line.

This is basically what I ended up with :) – Svish Oct 1 '10 at 9:58 So...basically you came up with a complicated expression for /\D/. – Daniel Standage Oct 1 '10 at 18:06 Well no \D is different than mine because it only matches non digits. Mine returns matches that include the entire string when a match is made while just \D could be multiple matches per line.My regex returns 4 matches while \D returns 17 (for each non-digit).

– Mike Cheel Oct 1 '10 at 19:20 @Mike Cheel I see. If that's what Svish was looking for, it definitely wasn't clear from his question. I see how that could be advantageous though.

– Daniel Standage Oct 1 '10 at 23:57 @Daniel, how was that not clear from my question? I even had 5 examples where I marked the strings I wanted matched... – Svish Oct 1 '107 at 12:46.

This will fail if there is a digit in the string as far as I can see – Svish Oct 1 '10 at 9:56 @Svish: your statement makes no sense. – SilentGhost Oct 1 '10 at 11:06 @Svish, maybe you should actually try it out before saying something. It is much more concise than the answer you selected, and it does work.It will not fail if there are digits in the string, it will only fail if it cannot find a "not-digit", which is exactly what you asked.

– Daniel Standage Oct 1 '10 at 13:47 I did. And this does not match a string that does not contain only URL2 matches a single letter that is not a digit. If I put that between a ^ and a $ for matching a string, it matches only the first of my test strings.

– Svish Oct 1 '10 at 12:43.

I would do: /^0-9/ That means that there has to be at least one character that is not a number, but the rest of the string could be anything.

You could simplify that to /^0-9/ – PP. Sep 30 '10 at 13:59 @PP, I am not exactly sure of general regular expression syntax, but I assume that the / means "any character"? – Justin 'jjnguy' Nelson Sep 30 '10 at 14:06 it denotes start and end of regex.

Not "any character". – SilentGhost Sep 30 '10 at 14:11 This would just match a single character wouldn't it? And if the string contained a single digit, it would fail.

– Svish Sep 30 '10 at 9:57.

D*a-za-z\d*$/ May be a digit at the beginning, then at least one letter, then letters or digits.

Since you said "match", not just validate, the following regex will match correctly \b. *a-zA-Z+. *\b Passing Tests: abc a4c 4bc ab4 1b1 11b b11 Failing Tests: 123.

Jjnguy had it correct (if slightly redundant) in an earlier revision. . *?

^0-9. * @Chad, your regex, \b. *a-zA-Z+.

*\b should probably allow for non letters (eg, punctuation) even though Svish's examples didn't include one. Svish's primary requirement was: not all be digits. \b.

*^0-9+. *\b Then, you don't need the + in there since all you need is to guarantee 1 non-digit is in there (more might be in there as covered by the . * on the ends).

\b. *^0-9. *\b Next, you can do away with the \b on either end since these are unnecessary constraints (invoking reference to alphanum and _).. *^0-9.

* Finally, note that this last regex shows that the problem can be solved with just the basics, those basics which have existed for decades (eg, no need for the look-ahead feature). In English, the question was logically equivalent to simply asking that 1 counter-example character be found within a string. We can test this regex in a browser by copying the following into the location bar, replacing the string "6576576i7567" with whatever you want to test.

Javascript:alert(new String("6576576i7567"). Match(". *^0-9.

*")).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions