Filtering specific word form sentence by regex - regex

I am trying to make a regular expression which will give an error when user will give specific input like feat, ft. I do want to allow this kind of input in a sentence. How can I solved this problem.
For example:
The feat-incorrect
featable-corroct
rahin (feat)-incorrect
feat-incorrect
I create one
regex: /^(?!.(feat|artists|Diverse artister|Feat|Feat.Featuring)).$/
in this regex
featable- is incorrect. But I need this one correct
has Anyone solved this kind of problem? Thanks in advance.

If your question is how to create a REGEX that selects whole words and not part of a word then try something like this:
\bfeat\b

If you want the only correct word to be featable then use \bfeatable\b
check out this Regex Expression builder, its useful. the builder would highlight the correct words for the expression you put.

Related

What is the proper way to check if a string contains a set of words in regex?

I have a string, let's say, jkdfkskjak some random string containing a desired word
I want to check if the given string has a word from a set of words, say {word1, word2, word3} in latex.
I can easily do it in Java, but I want to achieve it using regex. I am very new to regular expressions.
if you want only to recognise the words as part of a word, then use:
(word1|word2|...|wordn)
(see first demo)
if you want them to appear as isolated words, then
\b(word1|word2|...|wordn)\b
should be the answer (see second demo)
I am not able to understand the complete context like what kind of text you have or what kind of words will this be but I can offer you a easy solution the literal way programmatically you can generate this regex (dormammu|bargain) and then search this in text like this "dormammu I come to bargain". I have no clue about latex but I think that is not your question.
For more information you can tinker with it at [regex101][1].
If you are having trouble understanding it [regexone][2] this is the place to go. For beginners its a good start.
[1]: http://regex101.com [2]: https://regexone.com/

Regex for Word.AnotherWord

In Vb.NET I want to check a string if it is something like:
package_name.Procedure_name or
PackageName.Procedure_Name_Something_Else or
package_name.ProcedureName
So I need something like: word.otherWord
My problem is that I have tried many regexs but I wasn't able to achieve my goal.
The latest regex expression that I tried is : ([\w-#]+\.)+([\w-#]) which matches up to the first character after the dot.
Can anyone show me a direction or a hint?
your regex should be
[\w-#]+[.][\w-#]+

Issues with RegEx

I am trying to make an if-then-else statement using RegEx. I want to match the text if it contains Monty and also contains Python. Also the text should get matched if Monty is not present in the text.
RegEx
(?(?=Monty)(?(?=Python).*|)|^.*).*$
Kindly help!
How about this:
(^(?!.*Monty(?!.*Python.*).*).*$|^.*Python.*Monty.*$)
This passes my tests, but let me know if it works for you.
I am not versed in lookahead regex but just tried to build the regex from what I understood from above description. Check the link to see if this is what you are trying to do.
try this instead
((?=Monty)((?=Python).*|)|^.*).*$

Regular Expression for recognizing files with following patterns az.4.0.0.119.tgz

I am trying to find a regular expression that will recognize files with the pattern as az.4.0.0.119.tgz. I have tried the regular expression below:
([a-z]+)[.][0-9]{0,3}[.][0-9]{0,3}[.][0-9]{0,3}[.]tgz
But, no luck. Can anyone please point me in the right direction.
Regards,
Shreyas
Better to use a simple regex like this:
^([a-z]+)\.(?:[0-9]+\.)+tgz$
You just forgot one number part:
([a-z]+)[.][0-9]{0,3}[.][0-9]{0,3}[.][0-9]{0,3}[.][0-9]{0,3}[.]tgz
or
([a-z]+)[.]([0-9]{0,3}[.]){4}tgz
Depending on where and how you use the regex, you might want to surround it in ^...$.
Your pattern has 4 chiffers group, your regexp only 3.

Regex, how to select all items outside of selection group

I'm a Regex noob and am pretty sure I'm not going about this in the most efficient way - wanted to get some advice.
I have a Regex expression ((\w+\b.*?){100}){1} which selects the first 100 words of my string, the length of which varies.
What I want is to select the entire string except for the first 100 words.
Is there syntax I can add to my current expression to do this, or am I better off trying to directly select the rest of the text instead.
Also, if anyone has any good resources for improving my Regex knowledge, i'd be very appreciative. Thus far I've found http://gskinner.com/RegExr/ to be very helpful.
Thanks in advance!
If you use this, you can refer to everything else as group 3 noted as $3
This one will treat hyphenated words as one word.
(\w+(-\w+|\b).*?){100}(.*)
Regex training Here