Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
What would a Regular Expression need to allow characters and numbers only, no special characters or spacing in asp.net mvc5?
You generally use ranges such as [a-z] and [0-9] to filter out just characters and numbers with an asterisk after it *
I don't have a copy of MVC 5 handy so I don't know what the particular syntax is.
A regex for that often looks like:
([0-9]|[A-Z]|[a-z])*
It will be very similar in asp.net or mvc, likely.
That searches for all alphabetic characters from a to z, and all numbers from 0 to 9. The asterisk makes it search for multiple characters and not just a single character at a time. The pipe character says "or". Search for characters upper case, or characters lower case, or numbers. The brackets help sort groups.
As I said though you will have to figure it out the specific syntax of your regex library that your programming language uses, as they can differ. There are perl style regexes, and many variations. The above is just a sample. You can test at:
http://regexstorm.net/tester
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have some alphanumeric strings. From that I have to find out those strings which satisfy the following condition,
There should be only one character in the whole string and that should be 'e'
'e' should not present at the beginning or end of the string it should be present at the middle.
I want to pick strings like 43e4234,435345e5
I can do the same thing in ruby, but as i have huge number of strings i want to go with regular expression only
This should work:
/\A[^a-z]+e[^a-z]+\z/i
It means :
Beginning of the string
at least one non-letter
'e'
at least one non-letter
end of string
Here's an example :
https://regex101.com/r/H9oza7/1
Use /^[^a-z]+e[^a-z]+$/im if you want to match lines inside a string.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm using Ruby 2.4. I have a string with letters and numbers, something like
str = "123abc234abb"
How do I find all the letters occurring after the last number in the string? For example, if I applied the function to the above, it would yield
abb
You could use a positive lookbehind:
"123abc234abb"[/(?<=\d)?[a-zA-Z]+\z/]
#=> "abb"
Try this
str.rpartition(/\d+/).last
How does this work?
rpartition splits the string into three parts, using reverse matching
last picks the post-match part from the three results
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
what decimal separators are in use around the world? (I have a few places between programs where I must exchange a floating point number as a string without a thousands separator.) yes, I know this isn't a fantastic idea...there are many ways this could be done but more serious improvements will need to come later...
I know of "," and "." but are there any others?
http://en.wikipedia.org/wiki/Decimal_mark
There you have a list of separators (basically ",", "." and " " in writing and also "'" and "˙" for handwriting), with many examples of all of them in different countries.
Since this is applied to programming, you should only worry about ",", "." and " ", that is, unless you are doing some OCR'ing.
Check this out: http://mathworld.wolfram.com/DecimalPoint.html. It makes it sound like the decimal point, the decimal comma and the raised period are the only things in use.
You can also check out wikipedia http://en.wikipedia.org/wiki/Decimal_point but it doesn't really say much else.
I checked this on .NET environment by looping all CultureInfos framework had (806). The result set was ".", "," and "/". The last one was Persian CultureInfo.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Searching for symbols is a common in programming, especially when you are new to a language.
For example, I had a question about the :: operator in Python, and that is not searchable. People looking for things like this or Object [] (array of Objects), would not find what they want.
Why do search engines seem to ignore symbols completely? They are just characters like any others. I can see why
it would be hard to extract semantics from symbols compared to words (eg: a search engine can figure out that "find," "finds," "found" are all related, if not the same word),
but is it really that hard to search for them?
I can also see why in everyday use you'd want symbols to be ignored, but how hard would it
be to make it look for something explicitly (eg: "::" would search for ::)
Check out this article on Interpreting Google Search Queries.
Specifically, section 9
Google ignores some punctuation and special characters, including ! ?
, . ; [ ] # / # < > .
Because punctuation is typically not
as important as the text around it,
Google ignores most punctuation in
your search terms. There are
exceptions, e.g., C++ and $99.
Mathematical symbols, such as /, <,
and >, are not ignored by Google's
calculator.
[ Dr. Ruth ] returns the same results
as [ Dr Ruth ]
What if you're seeking information
that includes punctuation that Google
ignores, e.g., an email address? Just
enter the whole thing including the
punctuation.
* [ info#amazon.com ]
Be aware that web pages sometimes
camouflage email addresses to make
collecting such information difficult
for spammers. For example, on some
sites you'll find the # sign in an
email address replaced with the word
“at.”
Now we'll look at some special
characters that Google doesn't ignore.
To minimize the number of entries in the index.
A search engine doesn't have to ignore them though. For example, it seems Google Code doesn't.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need a regular expression for my Ruby on Rails application for the password field.
Any character or number or symbols is allowed except space.
If this is client-side validation in Javascript (or any language other than Ruby), this expression will match a string with no whitespace (\S) at least one character (+), no max:
^\S+$
Ruby is the only language that uses multi-line mode by default, so the start-of-line ^ and end-of-line $ behave differently (they match once per input, no matter how many lines). So, if you are validating the input in Ruby, you'd need to use \A for start-of-line and \Z for end-of-line.
\A\S+\Z
All except spaces, do you need to narrow the results a bit more than this?
/[^ ]+/
This is without minimum length (or rather, with minimum length 1):
^\S+$
With minimum length 8:
^\S{7}\S+$
or, if your regex engine supports it (don't know why it wouldn't):
^\S{8,}$