The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [regex]

Regular expressions provide a declarative language to match patterns within strings. They are commonly used for string validation, parsing, and transformation. Since regular expressions are not fully standardized, all questions with this tag should also include a tag specifying the applicable programming language or tool. NOTE: Asking for HTML, JSON, etc. regexes tends to be met with negative reactions. If there is a parser for it, use that instead.

0
votes
0answers
16 views

How can I use two patterns in re.search()?

I have the following string string = DdCcaaBbbB. I want to delete all the combinations of the same letter that are of the following form, being x any letter: xX, Xx. And I want to delete them one by ...
-1
votes
2answers
20 views

How can I specify a variable as the first argument in re.sub

I only started python recently and have never written any code before. I used a regular expression to match a string in the input file (which was successful) but I am really struggling to find a way ...
-2
votes
1answer
24 views

Python regular expression to capture last word with missing line feed [duplicate]

I need to capture words separated by tabs as illustrated in the image below. The expression (.*?)[\t|\n] works well, except for the last line where a line feed is missing. Can anyone suggest a ...
0
votes
0answers
16 views

Rewrite Rule Issues

I hate to write this post but i've been working on this for far too long. We are upgrading a multilingual site and the language module that we are now using handles URL's very differently. We are ...
-3
votes
0answers
18 views

awk or sed: how to modify based on previous and next lines

I have a file like below * jhasjdhjh sample1 * oioieoirer sample2 * jsdhfjhdf * ppppppp sample3 * iouiuiouo I want it to be * jhasjdhjh * sample * oioieoirer * sampel2 * jsdhfjhdf * ...
-1
votes
1answer
20 views

Split strings that mix upper and lowercase in a well defined way

I have a set of strings of the form: Team XYZJohn SMITH / Jane SMITH TEAM RacersJim SMITH / Jane SMITH John McMahon RacingBob SMITH / Jane SMITH and want to split on the joined names to give strings ...
0
votes
0answers
13 views

How to properly populate mongodb nested schema in req.body?

I have a nested schema, and I am trying to populate that in req.body. However, I can only access first layer of the schema, the rest remain empty. I tried to test with postman: In the result, the ...
0
votes
1answer
26 views

How to use [^x] in a RegExp without matching the content of 'not x'? [duplicate]

I am working on a Regular Expression to match JavaScript keywords; my problem arises when trying to match single operators (+ , - , / , * , = , etc..). Example: I am trying to prevent matching '+' ...
1
vote
1answer
18 views

Regular expression to split the data frame string into columns in python

I am new to regular expression. I have to split a dataframe row into 3 columns based on the pattern using regular expression. Example row in data frame: "Sample String(just a / string) 04/04/2014 ...
1
vote
2answers
36 views

RegEx for a multiple line search and replace using sed

I need to have a RegEx that finds a \n in the middle of a line as a start point, anything before is random, and replace after 15 digits and 49 alpha on the second line. I need to replace all that by ...
0
votes
1answer
21 views

RegEx to match a specific format: 4 digits and 6 characters in a string [duplicate]

I'm trying to design a RegEx in C# to match 4 digits and 6 characters in a string. string str = "Hello World! ABCD112233 fsdf sdfsdf 234324 fdsfds 4234 efwedf34ref dfsdf34f34f"; that matches only ...
-1
votes
2answers
34 views

Extracting a chunk of text between <p> tags

So I've got some sample html that I am trying to parse and extract data from. This is what the data looks like: <div class="content"> <h1 class = “heading1”>MOVIE TITLE<h1> <h2 ...
2
votes
1answer
49 views

Regex in javascript in a very specific format

I have a input that has to format what's the user typing(actually it is info from his bank account). But the numbers have to be formatted in a certain way: the first 5 digits must be numbers. if the ...
0
votes
2answers
25 views

Get objects where lowercase/stripped name is equal to lowercase/stripped parameter in Django filter

I would like to get all products where stripped/lowercase version of name field is equal to stripped/lowercase version of input_product_name parameter in Django. How can I do this? Pseudo-code def ...
0
votes
2answers
42 views

Extracting string between punctuation, when present

I'm trying to extract a string after a : or ; and before a ; if the 2nd punctuation is present, then to remove everything after a ; if present. Goal result is a number. The current code is able to do ...

15 30 50 per page