Newest regex Questions

Q&A for professional and enthusiast programmers

Regex Pattern Replacer

input = ["hello \"shahrukh\" ", " hello \"dude \" "] ; output = ' [hello \"shahrukh\", hello \"dude \" ]' ; I basically need an output with all the double quotes removed if they are in the beginning ...

Regex matching 5-digit substrings not enclosed with digits

I want to extract 5 continuous digits from the string code I have written. re.findall(r"((\D|^)*)\d\d\d\d\d((\D|$)*)", s) but it can not pass the string "Helpdesk-Agenten (m/w) Kennziffer: 12966" ...

Python regex: “like” regex pattern?

I have this pattern: ^[0-2]{0,1}[0-9]:[0-5][0-9]$. It checks if entered string is of time format, like 01:20, 20:30 etc. The thing is, I need to check if value being entered is correct by symbol. ...

Detect specific url and add tracking parameters PHP

I've a question, that seems simple but who's causing me some problems. I've a text string that can contains multiple html tags, paragraphs and links (text link and/or html links ). I would like to ...

Checking if a string contains a number, and if so, getting the list from that position

Suppose I have a string "Monday-Saturday 11: 12 VIKAS KOHLI", then I want two resultant like "Monday-Saturday" and "11:12 VIKAS KOHLI" Similarly I have the same string "Monday-Saturday 11: 12 VIKAS ...

Regexec() not giving the desired result

I need to check whether the month is of the form 01-12.I made a regex and took input to check whether it matches the regex or not. Code- #include <iostream> #include<string> using ...

Dealing with shorthand characters in regular expressions

I have to built a NFA from a regular expression and then go through a text and found matching patterns. I used Thompson's construction to build the NFA when the expression contains only the alphabet ...

pythons regular expression [on hold]

BE Production SGGS CE&T, Nanded 78% PGDBM BIIB, Pune 70% SSC Gujrathi Highschool, Nanded 67% HSC Science College, Nanded 80% SAP SD Cert.Mumbai 80% I want to write the pythons regular ...

egrep xargs: no such file of directory

I am trying to find files with some pattern. I use egrep and xargs: egrep -riz "r[ée]section.{,150}(extra.{,5}art)" /home/data/ | xargs -0 egrep -li "(hanche|bassin|ac[ée]tab|cotyl|iliaque|f[ée]mur)"...

how to use a regular expression in verbose form with PHP [duplicate]

I have a regular expression (in verbose form) that validates UK post codes. (GIR\s0AA) | ( # A9 or A99 prefix ( ([A-PR-UWYZ][0-9][0-9]?) | # AA99 prefix with some ...

Find and replace *similar* lines in Notepad++

Initial Note: Please mark this as duplicate, if it already exists, I didn't know how to search for it. Have some lines in notepad that look like this: Line 1: a x a x a x a ... Line m: a y a y a y a ...

Regex multiline mode not working as expected for optional group

I have a next text source: PHPUnit 5.7.5 by Sebastian Bergmann and contributors. .....................E.....R................................. 61 / 1485 ( 1%) ..................... ...

Xpath: pass an 'include everything' parameter to [starts-with(…)]

Using Saxon HE/Xpath 2 To filter my xml file of a list of businesses by 'BusinessType' I pass a parameter (ie "Restaurant" or "School") to the xsl file: "java.exe" -jar "saxon9he.jar" -s:FHRS.xml ...

Regex notepad++ replace first character only

I have been going through some examples of similar questions here on how to find first character in data to replace with another character. This is the column delimiter in our data and I need to ...

C# find word with special character [on hold]

i have a text file. sometimes there is word with % sign in it. How do i find it ? for example: alpha%charlie is there in the file. How do i extract aplha%charlie ??

How to match string , special characters and HTML tags in Regex?

I'm trying to match a HTML text mixed with some normal strings . I've already do most of the job , but the problem with the string inside the HTML chars . So the text i'm trying to find would look ...

Grabbing text inside a <p> tag in between <b> tags plus a regex issue

Ok, so I have gotten really close and need help crossing the finish line. I have two pieces of text that I want to grab using Scrapy. Here is the format: <html> <div id="product-...

Regex to remove strings

I have i.e. this string: <span value="Abel" class="select-item ">Abel<span class="cd-dropdown-option"></span></span> I want to remove all except 'Abel'. With which regex I ...

Backreference non capture group in javascript regex

This is going to be a really short question... Lets assume I have a regex like: (Hello)(?:fooBar) How can I backreference it using \2? I know this works with normal capturing groups and that a non ...

Regex match strings based on a certain pattern

How do I match a string using Regex based on a pattern with certain amount of characters to look for? Example: |V.2|58| 10001|W20101|W20101|G00001||||學徒劍盾|8|9|768||-1|1||||||||40002||||||1|14||2||...

Regex for all name's shape [on hold]

I am looking for a dataset of all the name's shape, with whom create a regex that match all of these. For example, classic name: George Washington, Netherlands name: Paul van Saar, some American's ...

Capturing version numbers using regex python

Using a rest api I get the following forms of strings back: /primerjs-0.0.3-3.tgz /primerjs-0.0.3.tgz /0.0.3-16 I want to grab just the 0.0.3 part from the above strings. I came up with the ...

exporting regex strings to Android ressources

I want to export several regex strings to Android string ressources. Basically Android string ressources are XML, so I need to fulfill the XSD. On the other hand there is LINT with its ruleset, for ...

How can I replace the regexText with an array of bytes

I have a function and am doing it to overwrite a keyword in a doc file with array of bytes. Am confused how to do it.Please provide suggestions if (Directory.Exists(Temps)) { DirectoryInfo d = ...

RegEx expression to find only exact match with Capitalization variants

I want to filter down landing pages in Analytics to just see traffic from “/ph” and “/pH” only, and not include other pages that have like /ph-electrode-maintenance-calibration-guide. (ph|pH) didn't ...

php explode by comma ignore thousands seperator

I am scraping the following kind of strings from an external resource which I can't change: ["one item",0,0,2,0,1,"800.12"], ["another item",1,3,2,5,1,"1,713.59"], (etc...) I use the following code ...

How to grab everything between two words in a text with regex [duplicate]

I'm trying to grab a text enclosed between two words, but the problem is that i can make the regex grab all the text including especial character here is an example of what i'm trying to grab Example:...

Match between lines while skipping pattern with Regex

I've been trying to match between lines while skipping a pattern. I'm using the re.DOTALL regex flag. What i need to extract is CHINTHAPUDI<br/> CHINTHAPUDI<br/> from between Electors ...

Would theses regexes ever match: (^(?=street.*))name mm(^(?=.*yy)) [duplicate]

I was not quite sure how to formulate the posting title, but I think the above will do at a first approach. I encountered those regexes in a customer's project and I am wondering, whether these ...

Can a python dictionary use re.compile as a key?

We have 10-20 dictionaries that follow this basic format, the key is the value to be assigned and the value is the regex: osTypeRE = collections.OrderedDict([ ('WINDOWS', re.compile('^.*(windows|...

Text search with NFA built from regular expression

I have a NFA constructed with Thompson's algorithm https://swtch.com/~rsc/regexp/regexp1.html. I have to search a text for a matching pattern but I am not sure how the search is implemented. I mean, ...

Reading a record in a file which is split on multiple lines

ID|Text 1|Date|Text2 1|Hello There what a wonderful day|12th|Out in the market 2|Well I wish|13th|Sleeping 3|It is rocking, python is a great language to code|18th|what to do in this scenario 4|Text ...

Regular expression how to from value agent and username and number?

I have a regular expression requirement for a telephone dialpad, from where i need to parse agent name, username, a telephone number. Example random user inputs like following: ...

Convert this function to a stateless react component

I have this function that dims the trailing zero of a number, after the '.' ex. 123.456000 -> 123.456000 100.0000 -> 100.0000 456.999990 -> 456.999990 333 -> 333 the final html generated by this ...

split a string with comma and colon [on hold]

I have string like below var x = "123456:a,b,c,435213:r,567876:e,363464:t,y,u"; I want to split it like as below ["123456:a,b,c","435213:r","567876:e","363464:t,y,u"] I have tried to use following ...

regex replace words except in hyperlinks [duplicate]

I have created a php function to replace the words I want to highlight in a text. The only problem I have is that input text can also be some html code. This causes existing hyperlinks to break. ...

Regex to match event ID (Less greedy)

I wrote a basic Regex to match any of the specific event ID's 4727|4731|4759|4744|4749 The problem that I am having is that it is matching a pattern found in a non-standard event that is more than 4 ...

Java regex to test contains any letter but only 3 spaces between strings [on hold]

I am trying to form regex to validate a string pattern "part1 atmost-2-words part2". The part1 and part2 are fixed strings and in between that it can contain any letters but at most 3 spaces. ...

Regular Expression Nested Similar Strings

i have a string like this : "xxxxxxx File_6547845_Whateverishere_S_Md.Txt yyyyyyyyyyyyy File_14787547_Whateverishere_S.Txt zzzzzzzzzzzzz" and i want to only match the String that start with "...

Regex to fetch substring from a string

I am using notepad++ and trying to find/replace occurrences of a particular word in an XML file with another word inside a particular tag. For example: XML file contains <alerts> <...

Pseudocode regular expression

As a follow-on from this ages ago: Converting pseudocode into usable (using regular expression?) At the moment, if I input a string such as: unit.getCriteria('starts', 'name', 'P', 'M').setAward('...

Regex for specific string

The string should look like this "1-7;IN;dd" (For example, 2;IN;43). First value before semicolon should be digit 1 to 7. And last value after second semicolon should be 01 to 99 number. My ...

How to wrap a tag around a tag in a string - Javascript

I have a String. Say it looks like this: &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Web Page&lt;/title&gt; &lt;/head&...

imgur extract codes from links in C# Regex [on hold]

I'm trying to convert a imgur link to an embedded code. I've found this Regex that works to extract the imgur code in JavaScript. I need your help in a code that extracts one or more matching imgur ...

Understanding lookahead in R regexp

I'm trying to use multiple lookaheads to simulate an AND operator in R Perl-type regex with grep. However, I don't understand the output I am seeing. This is a sample code block a <- c("abcxyz", "...

Regex - Capture only numbers that don't have a letter next to them

I have a task to create program that'll match digits without numbers infront of them. For example: 6x^2+6x+6-57+8-9-90x I'm trying to use Regex to capture all numbers with + or - before them - ...

place a comma in front of the found REGEX (4 digits and a comma) in JAVA

I'm working in Java and trying to set a comma in front of a date with 4 digits. Example: Normal string: 'El Burro' Van Rankin,Jorge,5 June 1964,NULL I want the following output (placing a comma ...

Matcher.getMatcher() always returning false for a regular expression in java

I have to process one input String. So I made one regular expression and compile it like below. Pattern pattern= Pattern.compile("([^,]*),"+"([0-9]*),"+"([^,]*,[^,]*,)"+ "([0-9]*),"+ "([0-9]*),"+ "(,....

Ruby - validate user input against allowed characters

i am stuck at validating user input. i have set of allowed characters "R G B Y" and i am asking for user input. I want to validate if user inputs ONLY characters that are allowed ("R G B Y"). User ...

How to extract the first character from strings with specific patterns

I would like to extract the first number which follows a pattern( here it is *) c(" 2 X[0,JOHNSON] * 0 0 1 ", " 3 X[0,WILLIAMS]", " * 1 0 1 ", " 4 X[0,JONES] * 0 0 1 " ) here I am looking ...
Translating... 0%