261,162 questions
-5
votes
3
answers
87
views
JavaScript replace regex produces two trailing commas for "a,b,c " string
Background
I'm working on processing a comma-separated username list (for an ACL whitelist optimization in my project) and need to normalize whitespace around commas, as well as trim leading/trailing ...
-4
votes
0
answers
55
views
Replace text using sed, problem with regular expression [closed]
I have a file plenty of text strings like
text {\LXXX} more text
where XXX can be any character and its lenght is not necessary of 3 characters. I need to replace all {\LXXX} by {\LXXX}}, i.e., add } ...
Advice
0
votes
6
replies
79
views
Match a string not preceded by a pattern
I want to match a string according to a pattern but only when it is not preceeded by an other pattern.
const source = "abc.def.Ghi\n\
@:test(abc.def.Ghi2)";
const re = /(?!\()([a-z]\w+\.)+([A-Z]\w*)/g;...
5
votes
2
answers
130
views
Hex escape sequences in bash regex range have no effect
Here is a bash script:
#!/bin/bash
char=$'\x01'
if [[ "$char" =~ ^[\x01-\x20\x7F-\xFF]$ ]]
then
echo "Unprintable"
else
echo "Printable"
fi
The script ought to say ...
-2
votes
1
answer
128
views
Regular expressions for extracting text inside curly brackets [closed]
I'm working with some marked text and I need to extract information in order to use later. I want to use regular expressions from Python using the module re, but I can't construct the right expression....
-1
votes
2
answers
78
views
Force sumif() with wildcard and fixed pattern
I have a Google spreadsheet with the following values:
+------------+-----------------------------+
| G | F |
+------------+-----------------------------+
| Hours (G)...
-6
votes
1
answer
87
views
Best way to extract a names from a string [closed]
I have a function that takes a string as an input and tries to extract the name and surname. It is a combination of NER and regex to try to extract the names present. Is there a better or more ...
-3
votes
0
answers
82
views
How to delete evertything after .txt [closed]
I have tried \txt.*$, (^.*?\.[txt]+)(.*)$, (^.*?\.[.txt]+)(.*)$ and nothing matches
Here is an example of the file:
download_list/list_left/14khashintipasswordai.txt
download_list/list_left/...
0
votes
1
answer
68
views
How to access named capture groups in C++? [duplicate]
On Regex101, I have simple Regex with a named capture group in ECMAScript flavor:
(?<name>.*)
I'm trying to do the same thing in C++:
#include <iostream>
#include <regex>
using ...
1
vote
2
answers
87
views
Replace a long case statement involving regex with a hash
I'm parsing a number of text files of different formats. Some are csv, some are xml and some even txt. I have a case statement that checks if a certain string is contained in the first 100 bytes of a ...
-3
votes
0
answers
91
views
secure removal of tags from HTML content [duplicate]
The classical problem of HTML tag removal, to obtain a plain text content, may be usually addressed with patterns like : <[^>]+?>.
But what if you got this kind of content : <exampletag ...
-3
votes
2
answers
187
views
Regex to match all but this pattern [closed]
I have filenames with this pattern [a-zA-Z0-9]{10} and .txt extension. They might also contain a pattern like this [super] and it could be either before or after [a-zA-Z0-9]{10} with '_' separating ...
-4
votes
2
answers
111
views
RegEx in Javascript, Match multiline text between Tokens [closed]
I have this RegEx in JavaScript:
/^\d{4}-\d{2}-\d{2} ([a-z,]*)((.|\n|\r)*?)/mig
2025-11-13 bb Test.
2025-11-12 bb Mail von Test
testd
trest
Tes
2025-11-12 bb Mail v
Regex101
but I need the ...
Best practices
0
votes
4
replies
99
views
How to search through Unicode text with ASCII input in Python
I have a corpus of text which includes some accented words, such as épée, and I would like people to be able to easily search through it using ASCII input. Ideally, they would simply type protege or ...
2
votes
3
answers
162
views
Substitution problem for 2 same instances in one string by using regular expression substitution method [closed]
There is a task that says to replace NOUN words with any noun word possible while using regex substitution but issue is that, there are two of these words and each should be replaced separately.
The ...