Browse all latest questions tagged Regex
I'm using python but code in any language will do as well for this question. Suppose I have 2 strings. sequence ='abcd' string = 'axyzbdclkd' In the above example sequence is a subsequence of str...
Please consider the following example, which finds the first String in a list that contains the Substring "OH": list = ["STEVE", "JOHN", "YOANN"] pattern = re.c...
From this link I used the following code: my_other_string = 'the_boat_has_sunk' my_list = ['car', 'boat', 'truck'] my_list = re.compile(r'\b(?:%s)\b' % '|'.join(my_list)) if re.match(my_list, my_othe...
I have this string with text mixed together with tabs, spaces, CR/LF and maybe more special characters as well. How can I go about cleaning the string so that I only have the words left. I tried the...
I'm currently using regular expressions to search through RSS feeds to find if certain words and phrases are mentioned, and would then like to extract the text on either side of the match as well. For...
Is there any examples of regex for entering text(letters) without emojis ? I tried to inverse regular expression but it works not correctly /(?!:\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\...
This is my code to determine if a word contains any non-alphanumeric characters: String term = "Hello-World"; boolean found = false; Pattern p = Pattern.Compile("\\W*"); Matcher m = p.Matcher...
Ruby's regular expressions have a feature called atomic grouping (?>regexp), described here, is there any equivalent in Python's re module?
A function that will insert 1st parameter after n(2nd argumanet)th times from backward const string = "abcdefg"; const backWardInsert = (str, num) => { // Do the stuffs // Here is what I"ve...
I need a regular expression that does not start with a dot or end with [-_.]. This regex works but fails for the first condition; it does not start with dot: ^[A-Za-z0-9][^.]*[^-_.][A-Za-z0-9]$ Fo...
I am using the following code: CARRIS_REGEX=r'<th>(\d+)</th><th>([\s\w\.\-]+)</th><th>(\d+:\d+)</th><th>(\d+m)</th>' pattern = re.compile(CARRIS_REGEX,...
What's the best way to validate an email address in JavaScript with a regular expression?
When using re.sub() part of re for python, a function can be used for sub if I am not mistaken. To my knowledge it passes in the match to whatever function is passed for example: r = re.compile(r'([A...
I have finally figured out how to validate inserted russian text in my tag by mask = jQuery.extend({unitprmask:/^\d+(\.\d{1,1})?$/,expressmask:/^\d+(\.\d{1,1})?$/,qtymask:/^\d+(\.\d{1,1})?$/,y...
I would like to do something when finditer() does not find anything. import re pattern = "1" string = "abc" matched_iter = re.finditer(pattern, string) # <if matched_iter is empty (no matched fo...