Latest Questions tagged Regex

Browse all latest questions tagged Regex

36
Votes
Published 31 Aug, 2022
Python - Regex subsequence matching

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...

25
Votes
Published 29 Aug, 2022
Python - Matching strings with re.match doesn't work

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...

65
Votes
Published 20 Aug, 2022
Python - Why does flake8 give the warning F821 -- undefined name 'match' when using match.group(0) with Python 3

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...

16
Votes
Published 29 Aug, 2022
Python - Python - Locating the position of a regex match in a string?

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...

98
Votes
Published 04 Aug, 2022
Jquery - jQuery/JavaScript clean string so only words exist

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...

2
Votes
Published 16 Apr, 2022
Javascript - Regex for entering letters without emojis

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[\...

17
Votes
Published 04 Aug, 2022
Jquery - How to write a multilingual regex validation for Russian + Persian + Chinese + English languages?

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...

1
Votes
Published 23 Apr, 2022
Javascript - How can I insert a character after every n characters in javascript from backwards?

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...

34
Votes
Published 26 Apr, 2022
Python - Different behavior between re.finditer and re.findall

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,...

42
Votes
Published 01 May, 2022
Python - Do Python regular expressions have an equivalent to Ruby's atomic grouping?

Ruby's regular expressions have a feature called atomic grouping (?>regexp), described here, is there any equivalent in Python's re module?

74
Votes
Published 24 Aug, 2022
Python - Regex not start with dot or end with dot

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...

70
Votes
Published 03 Aug, 2022
Jquery - Trying to remove non numeric characters from textbox using jQuery

I'm trying to remove a character as it's typed/keyed up to test whether it's a number or not, if it is a number, keep it, if not, remove it. It can be more than one digit. for example, I type in a "d"...

46
Votes
Published 09 Jul, 2022
Jquery - jQuery Youtube URL Validation with regex

I know there is plenty of question answered over here https://stackoverflow.com/questions/tagged/youtube+regex, but not able find a question similar to me. Any body has the JavaScript Regular express...

58
Votes
Published 21 Aug, 2022
Java - Java regex: check if word has non alphanumeric characters

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...

84
Votes
Published 06 May, 2022
How to count string occurrence in string?

How can I count the number of times a particular string occurs in another string. For example, this is what I am trying to do in Javascript: var temp = "This is a string."; alert(temp.count("is")); /...