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.

Filter by
Sorted by
Tagged with
0
votes
0answers
2 views

Regex for removing characters between brackets

I am using the following regex to remove items in a sentence that falls within brackets \(.*?\) So in this sentence anything between (DFKJERLjDLJLF) gets removed. But if there are more than one ...
0
votes
0answers
16 views

Go regular expression with positive lookbehind

I'm trying to write a function in Go which will replace foobar with foobaz, but only if bar is preceded by foo. It seems to me that the regexp.ReplaceAll function together with a positive lookbehind (...
0
votes
2answers
24 views

regular expression

Here is a part of the data Broan Range Hood (BP130WWN) - White Broan Range Hood (BP130BLN) - Black Broan Range Hood (GP124WWN) - White Broan Range Hood (GP130WWN) - White Broan Range Hood (QS130WWN) -...
1
vote
0answers
29 views

How to use regex in python to parse csv data that spans multiple lines

I have the following text in a larger text file: CHANNEL = ['AngR', 'Time', 'Disp', 'Velo', & 'Acce', 'Load', 'Forc', 'BLod'] UNIT = ['deg', 's', 'ft', 'ft/s', 'ft/s^2', & 'N', 'lbf', ...
0
votes
1answer
12 views

Google App Scripts regex body.findText(searchPattern) function returns null

I have the following content in a google document, it's just text with some specific syntax: <li sheet="experiences"> {{company_name}}, {{job_location}} — {{job_title}} MONTH {{from}} - {{to}} ...
-1
votes
1answer
25 views

Java Regex match with grouping using ()

When trying to match using this regex: TEST_([[a-z]+[0-9]*-){0,1}DD[0-9]{0,2}-ENV I get an error: Unable to execute regular expression. java.util.regex.PatternSyntaxException: Illegal character ...
0
votes
1answer
27 views

re.findall() creating a single list

I'm very new to programming so forgive my ignorance. I'm trying to use [0-9]+ to extract all the numbers that are scattered throughout the text. Using the below program I end up with a list for each ...
0
votes
0answers
21 views

How to remove all numbers including (+/-) signs and Scientific from a string using python? [duplicate]

Test string: a=-22.083, besides - don't do that, c=92E-4, d=121, e=12E+10 Expected result: a=, besides - don't do that, c=, d= Note that any of the numbers can be +/- or scientific. Digits ...
1
vote
1answer
17 views

Regex Issue when log format has multiple ip's

I have an issue with fluenTd log parser. The following config works fine when there are 2 ip’s. expression /^(?<client_ip>[^ ]*)(?:, (?<lb_ip>[^ ]*))? (?<ident>[^ ]*) (?<user>...
-1
votes
1answer
33 views

Replace all characters between two characters in python

I'm trying to replace all characters between two characters. This is gonna be my input string: P<HRVSPECIMEN<<SPECIMENC<<<<<<<K<K<K<K<KKKKKK\...
0
votes
1answer
21 views

get contet base on regex in to separate variables

Is it possible to get every part of string base on regex? For instance I have: #abc##!#[\s]+[\d] I can target variables #abc# with regex #.+?#. However I would like to have both captured and the ...
2
votes
2answers
33 views

re.sub for only captured group

Given the string: s = '<Operation dedupeMode="normal" name="update">' I would like to change the dedupeMode to manual. For example, the end result should be: s = '<Operation dedupeMode="...
-2
votes
0answers
23 views

How do the following regexps in python work? [closed]

I am trying to understand how regexps works, and I am struggling to understand the below output: s = "b ab\naab 123" m = search("((a?)b([^a]*))(a?)b", s) # ? is zero or one assert isinstance(m, ...
0
votes
1answer
13 views

Separate part of script tag in DOM on loading page by regex

I want to separate part of DOM that contain Javascript tag with variable named matchData that is a Object like below in laravel: <div> some data <div> <script type="text/javascript"&...
1
vote
2answers
32 views

filter list markup in markdown with regex in javascript

I have the following regex: \^(?:[0-9]|\-|\+)[\s\S]*?\n\n\gm, which should match only for list markups in markdown. There are two problems remaining, first I get match with --- and second with ++text ...
0
votes
0answers
45 views

Javascript search string for json objects

I'm working on a project which using files containing string of text for input. The text also contains multiple json data. There could be one or several hundred of them in a file. They take the ...
-1
votes
1answer
30 views

How to write a regular expression to extract the account number from the bank passbook?

I need a regular expression to extract the number if my list contains account no and also if my list contains account number. I tried something like this. def check(extracted_text, words): for ...
2
votes
1answer
42 views

Snowflake SQL, how to lookahead until a certain occurrence of a value

Below is a sample of the text that I am working with. --- info1: * val: "A" --- Type: * answers: * - !<string> * val: "B" * - !<string> * val: "C" --- info2: * val: "D" --- ...
2
votes
2answers
42 views

re not matching when using an OR

I am trying to match dates (number in this case) from the following string: mystring = '_20180701_20190630' I am using the following code: re.findall(r'(?:\A|_){1}([0-9]{4}[_]{0,1}[0-9]{2}[_]{0,1}[...
1
vote
2answers
25 views

Regular expression group/substitution question

I have the following two regular expressions. My goal is to extract everything after "EX" Example 1: (^[EX]{2})(\w+) Example data EX12456 https://regex101.com/r/6QqHwf/13 Match Information shows ...
-2
votes
1answer
31 views

Using a regular expression to remove a uppercase letter if it's previous and next letter is lowercase?

I am new in regular expression. I want to remove a uppercase letter if it has lowercase before and after it. If the input is "I wilYl go theXre" then the output should be "I will go there". How can I ...
-1
votes
1answer
27 views

How to remove alpha characters from timestamp using RegEx?

I have timestamps in a field and would like to remove the 'T' and the 'Z' in the value. An example value is 2019-11-01T14:47:43Z. I would like to use a RegEx to solve this problem. I plan to use this ...
1
vote
1answer
24 views

Regex: a number vs. a backreference to a capture group

I've been studying regular expressions, and I'm scratching my head on this one. On this page (https://www.regular-expressions.info/conditional.html) I see that, in a conditional regex, a reference to ...
-1
votes
1answer
27 views

Regex group match using shell [duplicate]

I am trying to match a pattern and set that as a variable. I have a file with many "value=key". I want to find the value for key "fizz". In the file I have this string fizz="something_cool" I try ...
-2
votes
0answers
30 views

Extract the href in VB using RegEx

I am trying to build a newsreader to scrape the headline links on https://post-gazette.com/news/, each of which looks like the snippet below. Each a headline element contains the phrase "pgevoke-...
2
votes
1answer
30 views

Why isn't this repeated inner group matching in regex? [duplicate]

I'm trying to parse the following LaTeX string: \graphicspath{ {outputs/tikz/turnover/} {outputs/tikz/health/} {outputs/tikz/flows/} {outputs/model/figs/compare/} {outputs/model/figs/...
1
vote
2answers
49 views

How to explode mySQL column into REGEXP?

I have a column show_only_on that contains value with commas , as goodevening,contact,goodbye and I want to split the value of the show_only_on as below and use the | instead of ,: AND ('...
0
votes
5answers
56 views

Regex to not allow '.', '_', '-' at String Start or End and should not have consecutive '.' and the rest all special characters should not be allowed

the output should be like .test_test1-test - INVALID test2_test-test. - INVALID _test.test-test- - INVALID test.test-test - VALID test._test-test - INVALID The current expression that i have is ...
-1
votes
1answer
41 views

How different ^ & ' ˆ' character are from developer perspective? [closed]

In my application's UI, I have free text box where if I enter ^ character from my Mac it's being saved successfully but if I use 'ˆ' (only ^ character without single quotes), it is giving error. Now I ...
-1
votes
2answers
22 views

How can I Find which row to split a column into two new ones?

I am working through a DataFrame trying to clean things up, and came across a bit of an unusual element. Two test values are represented in the same results column posted below. I would like to split ...
-3
votes
0answers
27 views

Matching a number in a file name [closed]

What would be the regular expression that would pull out the 5021 from the text file name? Sample file name: Print DE_5021--19-11-08--15.14.50.txt My thought was: ^_[0-9]$
0
votes
0answers
28 views

Character to character regex when character the same

I'm trying to capture the text in a large markdown doc from on ## Header to the next for export into separate files. ##(.*?)(?=##) Don't work because the initial ## is the same as the Positive ...
0
votes
1answer
18 views

Extracting text from PDPage (PDFbox library)

I have a function that extracts text from whole PDDocument object because PDFTextStripper accepts PDDocument and doesn't have a function to accept PDPage to gettext ,so i am stuck on understanding how ...
-2
votes
0answers
12 views

can't resolve simple preg_match return [duplicate]

Créer une fonction qui s'appelle verificationPassword(). Elle prendra un argument de type string. Elle devra retourner un boolean qui vaut true si le password respecte les règles suivantes : Faire au ...
0
votes
1answer
25 views

Treat every whitespaces as the same character in Regex [duplicate]

I made a regex to highlight keywords found in a text by another tool. new RegExp(highlightedKeywords.map(v => `\\b${v}\\b`).join('|') || /.^/, 'gi'), match => `<mark>${match}</mark>`...
0
votes
1answer
67 views

JSON Object restructuring advice?

I'm about to embark on restructuring a large quantity of JSON Object data to a different format for this class assignment i'm working on for next summer. Unfortunately, the data in its current state ...
0
votes
1answer
28 views

Complex regex separator in java

I would like to split a String with a very specific separator. ex. Text : hello%!%!%;toto%!%;titi%!%!%;tata%;big%;level!%%;popo The separator must be "%;" and have to be: specifically in this ...
0
votes
2answers
42 views

Regex to find lines containing numbers, starting with text, but removing text from the ocurrence

Having the following input: Testing 42702434884 Testing 064352729-13 05.994.401/0001-53 Testing 134.632.125-03 I am trying to get lines containing numbers, considering only lines starting with text,...
1
vote
2answers
52 views

Search the similarity of 2 strings in java using part of word matching, not cosine similarity

Hi I want to compare 2 strings by part of the words appear in other string. for example: I have 4 strings: A) "white snow ball" B) "super exciting" C) "white image superdupercold" D) "cold" and ...
2
votes
3answers
35 views

Regex: get number after and before specific substring

I'm new to regex and trying to get number after substring text and before first non-numeric value. I have: const str = 'fasdfsdanvczx fdasvczx text 321,fasdgasdf'; str.toLowerCase().match(new RegExp(...
-3
votes
1answer
30 views

Date Regex with special character as optional pre element [closed]

Date Regex with special character as optional pre element I need a date regex for YYYY-MM-DD, plus the following four case: 1978-12-20 >1978-12-20 >=1978-12-20 <1978-12-20 <=1978-12-20 ...
0
votes
1answer
16 views

Delete Files with mac terminal

I'm trying to use find in the terminal to delete some files that PyCharm has created seemingly at random. It's created duplicates of files like: manage.py manage 2.py manage 3.py index.js index 2.js ...
0
votes
0answers
9 views

apache rewrite rules do not work properly when url ends with slash

I wanted to redirect urls like example.com to https://www.example.com. I tried the following apache rewrite rules, but it did not work properly. RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com$...
1
vote
2answers
40 views

Bash/Perl/Regex - regex wont work with a single line but works with full file

The Goal: Read every line, extract information via regex, return it to the bash script The Problem: When the whole file is a string in the perl code, it work, however if its given line by line via ...
0
votes
1answer
11 views

Google sheet custom formula with SEARCH function using multiple words

The following formula works to make a search using a custom formula =SEARCH("release",$C:$C)) but dont work if I use the logical operator OR. Example : =or(SEARCH("release",$C:$C),SEARCH("prod",$...
0
votes
1answer
32 views

Find number witch kW/MW/kWp [closed]

Please help me write regex for this problem: I need retrieve information from this text "od 01. 01. 2015 do 28. 06. 2026 pevnú cenu elektriny pre stanovenie doplatku vo výške 387,65 eura/MWh, ...
-1
votes
0answers
22 views

Regexp: How to match every occurence of “|” but not “\|” [duplicate]

I want to split a string that's separated by |. The only problem: | is also a valid character of that string if prefixed (escaped) by a \. That means I want to split my string by every | but not \|. ...
0
votes
0answers
34 views

remove text between <script> and <\script> with a specific keyword [closed]

I am new to regex, and just downloaded visual studio code, with what I am trying to delete the following entries: <Placemark> <name>TAEE**_R**</name> ...
-2
votes
1answer
24 views

Difficulty to remove several parentheses in a string, using stringr, in R

I have the following string: x = '(example)' and I want to remove both parentheses, in one command, using stringr. I tried str_remove(x, '\(|\)'), but this removed only one parenthese (the first one)....
0
votes
3answers
36 views

I want to access four FASTA files, to print organism name from header line?

I tried it but it doesnt show any errors or warnings and output too??I need to print organism name from header line or first line of these FASTA files.. use warnings; use strict; my @ar=("seq....