M
M
Michael2015-07-02 22:15:11
JavaScript
Michael, 2015-07-02 22:15:11

Regular season. How to determine the presence of a certain fragment inside []?

Hello!
I have the following problem, there is some text that needs to be checked for the presence of non-alphabetic characters, but possibly having numbers and the symbol "_", for this a simple regular expression like the following
^[\W\d\_]+$
worked &: it is easy to determine, but I just don’t know how to make this fragment take into account inside the square brackets of the regular expression. I tried it as follows:
^[\W\d\_(\&amp\;)]+$(for a start, I would like to at least just &define it), but in this way the regular expression does not define a fragment in parentheses, but simply one of the characters in these brackets.
The question is how to compose a regular expression so that it correctly determines the presence of a given html character code, while the rest of the text should not contain any alphabetic characters.
For example, here is the text that this regular expression should correctly determine:

2345093489394-

&

_==+_)([email protected]#$%^&!///......000

, and here is the text that should not match the regular expression
2345093489394-

amp

_==+_)([email protected]#$%^&!///......000

I hope for your help. I myself can’t get anything out, I’ve been sitting for half a day on this problem and all without results.
Thanks to everyone who will respond!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Finnish, 2015-07-02
@finnish

^([\W\d\_]|\&amp\;)+$
This regular expression does not solve the "fragment inside []" problem, but the mentioned strings should be processed normally.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question