980 questions
-6
votes
1
answer
167
views
How to remove optional prefixes and suffixes from string
Product codes may contain 5 different prefixes CK0, CK, C, 0, K0
and two character suffixes from AA to AZ: AA,AB,...,AZ
Sample codes:
CK04721310AE
CK04721310AD
CK04721310AC
CK04721310AB
4721310AE
...
-4
votes
1
answer
97
views
regex - error with result - too many occurence [duplicate]
For example, I have this texte (without newline - it's important) :
<div> ffjdklfjdklfjs 2015 ddddd </div> sfsfsfsfsf <div> hkh/ <> -%=:;.éggggggggggg 2018 dsqkdlmqs </...
1
vote
0
answers
34
views
Regular expression to match an optional group in the middle of a string [duplicate]
I have a regex question that's been driving me a bit crazy. I'm parsing a file and need to match and extract specific parts of each line read. The lines come in two forms (ignore the syntax, I'm just ...
2
votes
0
answers
66
views
Regex a not follwed by b, stop over-capture [duplicate]
I have two possible cases in some XML.
Case 1, incorrect: <tag att1="text1"/>
Case 2, correct: <tag att1="text1" att2="text2"/>
So I am trying to find all ...
0
votes
0
answers
54
views
Python regex non greedy not matching substring when the pattern has string surrounding the variable part [duplicate]
I hate to post such specific questions as why a regex is not working, but I have been searching for someone with the same problem to no avail. It seems I am miss understanding something about ...
1
vote
1
answer
74
views
RegEx required to capture full word, space and • symbol in all instances within a varaible selection of text
I need to be able to select variable elements from the following ingredient list example.
I wish to collect the 'full word, space & •' in all instances.
INGREDIENTS: ALCOHOL DENAT. • FRAGRANCE (...
1
vote
4
answers
147
views
Regex to match prices with different digit
I am trying to write a regex with go to match prices that composed by at least five digits with comma on the price.
For example:
"10,400,000","10,900,000","500,000",
I ...
1
vote
3
answers
83
views
Regex to extract multidimensional keys using bracket notation
I need to retrieve all keys using pure regex.
I need to start with word field and after that need to capture all multiple keys..
field[somevalue][anothervalue]
I'm using this regex:
/^field(?=\[(\w+)](...
0
votes
0
answers
117
views
Convert PCRE2 to Extended POSIX RE, do I really require lazy?
I have written the following regex:
^project\(.+?version\s*:\s*'(.+?)'.*\)$
The first capture group will grab 0.9.20 from the following block of text:
project(
'waybar', 'cpp', 'c',
version: '...
1
vote
1
answer
2k
views
A quantifier inside a lookbehind makes it non fixed width
I am trying to write condition in look behind to prevent space removing in quotes and after specific keywords.
For example, I have a string str = "client_id like 'TACIENT 1%' or client_id < '...
1
vote
0
answers
44
views
I am looking for a regex to pick up all the trailing 0s after decimal from any number along with the decimal [duplicate]
Looking to pick up all those 0s which doesn't add any value to a number:
1.000 should give .000
0.000 should give .000
0.0080 should give me 0
however 10 should remain 10, only after the decimals I ...
1
vote
0
answers
69
views
Regex Multiple Capture Groups of Same Pattern inside a match
im new to regex, but i have a question i could not find a answer to.
i have a file that looks like this
more text
static abc_p ABC_P[] = {
/* Netz I */
{
N1
N1
N1
0,
{
...
5
votes
1
answer
165
views
Why is the regex quantifier {n,} more greedy than + (in Python)?
I tried to use regexes for finding max-length sequences formed from repeated doubled letters, like AABB in the string xAAABBBBy.
As described in the official documentation:
The '*', '+', and '?' ...
-1
votes
3
answers
507
views
Validate phone number in two different formats in Mongoose schema [duplicate]
The phone number I need to validate needs to be at least 8 characters long and has two possible formats:
Must be at least 8 digits like "12345678"
OR
Must have 2 or 3 digits before "-&...
0
votes
1
answer
143
views
Java Matcher matches() method to match the entire region against the pattern
I have a pattern (\{!(.*?)\})+ that can be used to validate an expression of format {!someExpression} one or more number of times.
I am performing
Pattern.compile("(\\{!(.*?)\\})+").matcher(&...
0
votes
3
answers
119
views
How do I regextract the second date in a string?
I am trying to extract the second date displayed in this string, however my code keeps extracting just the first date in gsheet:
String: BOT +1 1/1 CUSTOM IWM 100 12 SEP 22/7 SEP 22 184/184 PUT/CALL @...
0
votes
1
answer
43
views
Regex Quantifier Which Number of Occurrence Gets Tested First?
I'm completely new to regex and recently started learning it. Here's a part of my test string from which I'd like to find matches.
24 bit:
Black #000000
12 bit:
Black #000
My question is the ...
0
votes
1
answer
62
views
Set a multichoice regex to make its matching attempts always from left to right, no matter if another previous regex tries to capture more chars?
import re
input_text = 'el dia corrimos juntas hasta el 11° nivel de aquella montaña hasta el 2022_-_12_-_13'
#input_text = 'desde el corrimos juntas hasta el 11° nivel de aquella montaña y luego ...
2
votes
1
answer
46
views
Issue in pattern matching using python regex
i am facing issues while trying to cut out a substring from a string using python regex. the problem statement is that i want to take any substring matching the following format from a bigger string
...
2
votes
1
answer
45
views
Regex: Plus operator does not match. How many times my regex backtrack? [ ^ ]*
Regex: Plus operator does not match. How many times my regex backtrack? [ ^ ]*
function stripComments(code) { return code.replace(/\/\/.*|\/\*[^]*\*\//g, ""); }
console.log(stripComments(&...
1
vote
1
answer
71
views
How I create a smart splitting regex on special characters?
I am struggling to create a special regex, that tokenize in smartly the text. Some of the rules are:
Don't split on "," or "." if they appear between two digits. ex: "12,3&...
1
vote
0
answers
97
views
Golang `regexp`: Splitting a string with syllables `CV(N)(C)`
I am trying to split strings with that contain multiple forms like CV(N)(C), where
C = ptk
V = aeiou
N = mn
and elements in parentheses are optional, similar to regex ?.
My initial thought that, in ...
-1
votes
1
answer
47
views
Regex get certain information
I've stumbled with certain types of rows.
I parse this information
195/75 R 16 C X Wonder Van 110/108R 10PR Tourador
The groups, which I need
I've got the following regex
([0-9]+)?\/([0-9]+)\s*\w\s*([...
2
votes
1
answer
1k
views
Presto regular expression patter match multiple times
I'm trying to extract all the unicode characters of emojis using presto regexp_extract_all function, but its is storing everything as an individual element in the array. what is wrong with my regexp
...
0
votes
1
answer
76
views
Java Regex to validate group field pattern example - abc.def.gh1
I am just writing some piece of java code where I need to validate groupId (maven) passed by user.
For example - com.fb.test1.
I have written regex which says string should not start and end with '.' ...