Regex - Without Special Characters [closed] - regex

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 1 year ago.
Improve this question
I'm using regex to validate username
^[a-zA-Z]+\.[a-zA-Z]{4,10}^'
Unfortunately it doesn't affect if the the value contains special characters such as !##$%^&*)(':;
I would glad to get some help for Regex that contains:
Alphanumeric only (a-zA-Z0-9)
Length between 4 - 10 characters.

The conditions you specified do not conform to the regexp you posted.
the regexp you posted ^[a-zA-Z]+\.[a-zA-Z]{4,10}^ is erroneous I guess, because of the ^ in the end, it will never be matched to any expression, if you want to match with the ^ at the end of the expression, you need to escape it like this \^. but ^ alone means "here is the start of the expression", while $ means "here is the end of the expression".
Even though, it denotes:
It starts with alpha (at least 1).
there must be a '.' period character.
Now there must be at least 4 alphas.
The regexp you need is really is:
^[a-zA-Z0-9]{4,10}$
This says:
It starts with alphanumeric.
There can be minimum of 4 and maximum of 10 of alphanumeric.
End of expression.

Try this:
^[a-zA-Z0-9]{4,10}$

Related

what is difference of (b*a)* and (ab*)*? Or they are same language? [closed]

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 1 year ago.
Improve this question
what is difference of (b*a)* and (b*a)*? Or they are same language?
The first one is a greedy matching (the asterisk quantifier after the scope) - matches as many characters as possible. The second one is a lazy matching (the asterisk and the question mark) of the same pattern. Lazy means to match as little as possible characters.
Read more here: https://learn.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions
Your greedy expression (the first one) will match the first 4 characters in input bbbac. The lazy algorithm will simply match nothing, because zero length matching is the minimum allowed. Nothing here means an epsilon, and infinite number of epsilons are assumed to exist around every character.
If you translate these patterns to an ABNF grammar you get this:
main = *(*"b" "a")
If you translate it to a language it is:

Regex that does not repeat the same character 2 times in a row [closed]

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 2 years ago.
Improve this question
I need to make a regex to validate an amount in which it only accepts numbers, points (.) Optional, 1 comma (,) optional and that after the comma I have at least 2 more numbers, the farthest I've come is this
^(([0-9]{0,})+([.]?))+([,]{0,1}?)([0-9]{1,}?)+$
This works fairly well, the problem is that it allows me to put the period (.) Followed more than once for example (100 ... 000), this accepts it, but I need it to only accept one period (.) At a time, how do i fix it?
I need the regex to validate as follows
100 VALID
100.000,00 VALID
100. INVALID
100..00 INVALID
100, INVALID
100..000,00 INVALID
To prevent the same character (in this case a dot) appearing consecutively, use a negative look ahead anchored to start of input:
^(?!.*[.][.])<rest of regex>
In your case:
^(?!.*[.][.])(([0-9]{0,})+([.]?))+([,]{0,1}?)([0-9]{1,}?)+$
See live demo with test cases from question.
I'm not clear on what you actually want to match, but I don't need to understand that to answer your question, which was how to prevent the same character appearing consecutively.

Input mask wildcards in a PLC language, i need to represent 4 characters [closed]

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 3 years ago.
Improve this question
How do i use wildcards in my input mask in a PLC language (structured text)?
^^[0-9][0-9][A-Z][2][0]
main()
{
barcodeData = getBarcode();
if (match(barcodeData, "^^[0-1][0-9][2][0][P]*"))
{do something
}
else{dosomethingelse
}
}
This seems like a regular expression. There * is not a wildcard but a quantifier. It means that the preceding character or group can occur zero or more times. . is a wildcard. It means any character except newline. [...] is a character set. It means any character from the set.
. is a wildcard for one character.
.* is a wildcard for any number of characters.
[.] means exactly one dot.
.{4} means four wildcards.
You can use sandboxes and cheatsheets like https://regexr.com/ to test your regular expressions.

understanding the nitty and gritty of regular expressions [closed]

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 8 years ago.
Improve this question
need some talking through and explaining regular expressions as it seems obvious but then I will write one and it wont validate and I cant understand why.
I am using http://regexpal.com/ to test my expressions and am trying (ultimately) to validate a password. but to start I just want to simply match a string of words of 8 or more characters.
according to this http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/ I should have most of what I need. This webpage tells me that \w matches a word character and then a + does 1 or more. this matches every individual expression I am testing (great). now I want to match only those that have 8 or more characters. so 'messi' should not validate but 'lollollol' should. so I then wrote this (\w+{8,}) expression but nothing was highlighted, aka nothing validated. I used () brackets to try and group everything together but it made no difference. can anyone see where my thinking is going wrong?
You must need to remove the following + from your regex. Since + does the job of repeating the previous token one or more times, likewise {8,} would repeat the previous token that is \w exactly 8 or more times. So you don't need to include the + in this (\w+{8,}) pattern.
(\w{8,})
Use capturing groups if necessary or otherwise go for matching.
\w{8,}

Regex asterisk is not working in specified manner [closed]

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 8 years ago.
Improve this question
the following regular expression disallows other than numbers and periods. [^\d+\.?\d*]
but test string we give 12** asd it result wrong it matches 12**.
how does it match asterisk.
the following regular expression disallows other than numbers and
periods.[^\d+.?\d*]
No, it doesn't do what you want.
it result wrong it matches 12**
I can't reproduce that. In-fact it matched a string except 12**
Here is the explanation from regex101.com. Putting all together don't make much sense.
/[^\d+.?\d*]/
Negated char class [^\d+.?\d*] matches any character except:
\d Digit [0-9]
+.? One of the following characters +.?
\d Digit [0-9]
* The character *
Note : *, ? and + don't have their special meaning inside [] and all of them are treated as literal character
Probably you are looking for
[0-9.]+