Regular Expression to Match both Capital and Lower Characters [closed] - regex

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am writing script for screening words within contents and replace it with *, if matched.
I am using the following simple regular expression for screening words like apple, banana
(\bbanana|apple\b)
It match all words banana and apple within content but not Apple or aPPle etc.
I want to write regular expression which match word regardless which character is capital or lower.
If i replace content to lower characters it will solve problem, but i want to keep content in original state.

You can try something like this:-
/[A-Z]{3}([0-9]{1,4})?|[A-Z]{1,3}/i
In your case:-
/\b(banana|apple)\b/i

the /i switch does case-insensitive matching:
/\b(banana|apple)\b/i
I also moved your word boundary markers outside of the alternation.

Related

regex to match string not containg at least X characters [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am looking for a regex to match a string that doesn't contain at least three characters [a-zA-Z]
Valid Strings:
abc12345
asd
abc12321!!
Invalid Strings:
aa!
111!!!a
!!!!!!b
I would use:
(?:[^a-zA-Z]*[a-zA-Z]){3,}[^a-zA-Z]*
You can find an explaination of this regex here.
matches:
abc12345
asd
abc12321!!
a85ug
83nj%#8n2
doesn't match:
aa!
111!!!a
!!!!!!b
a59&*#g9
You can check whether the following regex matches the string:
[a-zA-Z]{3,}
If it doesn't match then the string is invalid.
Basically the {3,} part of the regex says the the previous character class should be matched at least three times. It's pretty flexible in that you can specify a minimum number and a maximum number of times required for a match like so: {MIN,MAX} and if you omit either MIN or MAX then only the value specified is used (i.e. {3,} means at least 3, whereas {,3} would mean at most 3)

How to start a RegEx statement at the 2nd position of a string [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a string
.HACK G.U. VOL. 1 REBIRTH
I'm using a tool that allows me to specify a RegEx statement that can be used in a replace operation.
I want the RegEx to find all the periods "." that start after the 1st position. The replace operation should return the following.
.HACK GU VOL 1 REBIRTH
Thanks
The following will do the trick:
(?<!^)(\.)
per http://rubular.com/r/w1apzTZLPk
Since Javascript doesn't support negative lookbehind, this can't be done in Javascript, but there are alternatives as discussed in http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript
One approach in this case would be to capture the previous character and replace it with the same content as part of the replacement process, as in:
(.)(\.)
Note: You don't need to use a capture group for the matching of the literal . in either of the above. I just used that technique to highlight the match in Rubular.

regex match anything between {esbmsg:header:xxxxxx} [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
How to match anything between {esbmsg:header: and }
like xxxxxx could be any string {esbmsg:header:xxxxxx}
Try with:
{esbmsg:header:([^}]*)}
Where [^}]* matches everything that is not } character.
Try this regex
{esbmsg:header:(.*)}
It will also allow you to have any character in value.
Well, if you want to capture only the content of your expression (the "xxxxx" part) the best approach is to use positive look ahead:
(?<={esbmsg:header:)[^}]+
Depending on how your content looks you might have to tweak the [^}] part. For further information on regex (or a detailed explanation of the expression above) I recommend the following:
Regex reference
Regex tutorial

RegEx help: Matching a set of words unless they are preceded by specific keywords [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Looking for some regex help. I need to match words/phrases e.g. "confidential" "top secret" "sensitive" unless they are preceded by other words, for example: "contain" on the same line ..
"This email may contain confidential information" - this would not match
"Please see the attached confidential document" - would match because "contain" does not appear before the keyword "confidential" on the link.
I looked at using negative lookbehind but it's limited by width, so it would not work. In my case, the preceding words can appear several words before the keyword I am trying to match. Thanks!
You would think lookbehind, but it actually needs to be lookahead:
/^((?!contain).)*(confidential|top secret|sensitive)/
Because of the lookbehind fixed-wdth requirement.

regular expression to match the same character being typed with different style [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm looking for a simple regular expression to match the same character being typed with different style, like : احمد - أحمد إحمد - آحمد
the word has a char that could be typed in different form.
thank you in advance.
You can use the following expression to match: احمد - أحمد إحمد - آحمد
/[\x{627}\x{625}\x{623}\x{622}]\x{062D}\x{0645}\x{062F}/u
I assumed you are using PCRE flavor, if you are using a different flavor then you should look how to specify Unicode code points using your flavor and what modifiers you need to pass the regular expression engine so it can deal with Unicode.
Regex 101 Demo