Questions tagged [regex]
Also known as regular expression or regexp, a description of a set of strings, often used for searching and validating strings.
2,091
questions
0
votes
1
answer
18
views
Search and replace doesn't work with sed busybox. getting sed: unmatched '/' error
I am trying to search a particular string and replace all occurrences within a file.
sed -i -e "s/$search_string/$replace_string/g" $filePath
I keep getting sed: unmatched '/'error on ...
0
votes
0
answers
36
views
Regex: Is it possible to substitute an input string but adjusted as a numerical value? [closed]
Completely new to Regex, been trying to read up on it via Microsoft Learn site, and testing it out at regex101, but I have one problem I can't seem to figure out.
We have an in-house software that ...
0
votes
3
answers
40
views
Powershell $idValue doesn't write the extracted ID, but writes "TRUE" instead -- why?
I am writing a Windows PowerShell script to split a text file based on a delimiter, and create output filenames with an incrementing number and a captured identifier string.
I've checked for syntax ...
2
votes
1
answer
25
views
Replace text surrounding a wildcard in Notepad++
So, many years ago when I started writing PHP code, I learned to format information sent from a form as such:
$_POST[itemnamehere];
Whether that was right or wrong at the time, it worked. However, ...
0
votes
0
answers
47
views
Passing `Set /p _var=/irc:` when used by findstr, the colon does not get processed the same as if I typed `findstr /irc:` Example provided
I have search through the undocumented 'findstr' thread, SS64 findstr-escapes as well as SS64, Escape Characters for how to include the colon in the following way; no luck with either.
Example batch ...
1
vote
1
answer
21
views
RegEx replacement in NotePad++
I need to replace many different lines in a html file where lines look like this:
<span lang="en-ca">random string</span>
with just
random string
For example
my<span lang=&...
-1
votes
0
answers
29
views
Regex substracting substitution
Yesterday, I think, I needed to quote strings in a PowerShell script.
The string was sandwiched between other stuff, and spaced out so it formed a table; it was something like:
…$somevar="1" ...
0
votes
0
answers
22
views
windows-equivalent of mac's "insert pattern" functionality for {find,search}ing/replacing text
surprised no one has asked this question yet.
is there any way to get the "insert pattern" functionality that is available on pretty much all mac apps with search and replace (except, ...
2
votes
1
answer
90
views
In Notepad++/Sublime Text 3, how do I make all text lowercase by regex, but only if specific phrase occured in the line?
Say I have text like that:
models/players/clonespac/CloneTorsoLieutenant
{
q3map_nolightmap
q3map_onlyvertexlighting
{
map models/players/clonespac/CloneTorsoLieutenant
...
0
votes
1
answer
48
views
Select last 5 words of a paragraph in Regex
I want to match last 5 words of every paragraph in a document. I am using Notepad++ and also Adobe InDesign GREP
Sample Data
Here you can find activities to practise your reading skills. Reading will ...
0
votes
0
answers
22
views
rstrip On Lines of text being piped through sed s
So I am trying to implement the rstrip function on lines of text being piped into sed s and am having troubles. This is what I have that I think should work:
cat file1.txt | sed 's/[[:blank:]]+$//g;' &...
0
votes
1
answer
40
views
Notepad++ Regex merged 2 sections into one line delimited
I hope I can explain correctly. I have the text below, which consists of 2 sections, 1- the body and 2- the title and each one is separated by a "----" delimited. I am able to mark this data ...
1
vote
0
answers
67
views
Replace ** to NULL in Excel
I have excel which contain ** as value along with other values across between Rows and Column. I'm trying to replace ** with NULL but using Find & Replace it's Replacing everything as it's taking *...
0
votes
1
answer
43
views
remove duplicate character from string in pure bash - works in CLI but does not work in script
I want to remove all duplicate minuses from a string using pure bash (no sed/awk/etc). This works great in CLI:
s="com---strig-3-1080p-----mp4"
echo "${s//+(-)/-}"
com-strig-3-...
0
votes
1
answer
120
views
Select all lines starting with a given string and ending with " with Regex [duplicate]
Using Regex I would like to select all the contents between two " of all the lines that begin with this string:
[2]
1 string data = "
I tried the following code:
(?<=\[2\][^=]+? 1 ...
-1
votes
1
answer
41
views
How to match arbitrary adjacent identical strings? [closed]
There are some repeating strings in my data that I need to find. They have a pattern that they repeat twice, and the repetitions are adjacent, with no space in between. They can have arbitrary lengths ...
0
votes
2
answers
58
views
Find and replace date with UTC date
I have file that looks like this:
[2024-01-20 15:23:00] hello world
[2024-01-20 15:42:00] bye
[2024-01-20 15:43:00] foo bar
...
Date in this file are in UTC+1 and I want to convert in to UTC
I tried ...
0
votes
0
answers
56
views
How to recursively search for files starting with ".#" under a path in zsh?
In the current working directory, la -a returns,
. .#program 2.py .DS_Store picker.py
.#picker 2.py .#program 3.py hw1 temp.test
.#picker.py .. hw2
I ...
3
votes
3
answers
595
views
Bash [[ test =~ regex ]] vs perl command result
Is the bash operator =~ equivalent to a perl invocation?
filename="test-33.csv"
regex="([^.]+)(-\d{1,5})(\.csv)"
With bash test:
if [[ "$filename" =~ $regex ]]; then ...
1
vote
2
answers
347
views
How to use the `tax[13]-eq-dc` regex in a Bash loop?
The following regex tax[13]-eq-dc represents two servers, tax1-eq-dc and tax3-eq-dc.
I'm trying to find a way to use it in a Bash do loop, but can't just get the correct syntax.
E.g., the following is ...
3
votes
1
answer
83
views
Surfingkeys browser extension has enabled, disabled, and lurk mode. How do I add a list of websites in surfingkeys to browse in the lurk mode?
Lurk mode is better than disabling suringkeys altogether. For example, Gmail website has list of abundant shortcuts, but still it's better to have surfingkeys' shortcuts as yourbackup. In lurkmode you ...
0
votes
1
answer
214
views
Trying to use regex to match the "?si=" on YouTube share links
I want to match the ?si= on the end of YouTube links using Regex so that I can filter submitted links to remove the ?si= and what comes after.
I want to exclusively match that ID, and not anything ...
0
votes
1
answer
74
views
RegEx in Microsoft Word Find/Replace to locate an unescaped semi-colon in index markers
I've got Find/Replace open, under More I have Use wildcards checked.
I have a LOT of index markers in my document, and I want to find semicolons inside the index markers that are NOT escaped. I want ...
1
vote
1
answer
77
views
Regex code for TeamSpeak3 ControlBot plugin
I want a code that doesn't kick Name_Surname but kicks anything else. My current code is :
^(?![A-Z][a-z]+(?:_[A-Z][a-z]+)*).*$
I need one more rule to add to this code.
I want to allow [C]...
0
votes
1
answer
132
views
How do I find and delete a string at end of a line?
I have lines with this kind of data:
SEQ 338 13 OPS POSN 1 THRU 10 LANG KO 3 MO TU WE TH FR SA SU
----------------------------------------------------------------------------
SEQ 339 6 OPS POSN 1 ...
1
vote
1
answer
239
views
RegEx to find TEXT plus up to 6 numbers
[Using Notepad **]
Seeking a RegEx to find all of the following lines that contains the word "SEQ", a space, and then anywhere from 3 to 6 digits:
SEQ 123
SEQ 1234
SEQ 12345
SEQ 123456
I've ...
1
vote
1
answer
144
views
If the Account has Expired, Delete the Account Details
What regular expression would I need to delete all the expired accounts.
Name: John Smith
Address: 123 Sample Road
Country: England
Membership Expires: January 26, 2023, 9:35 am -288 Days
Plan: ...
3
votes
2
answers
337
views
Extract text between the Tags
I am trying to extract Arabic text between the two tags. Here its <Content>some text in arabic</Content>
Sample Text:
<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/...
0
votes
1
answer
75
views
For eliminate the lines with Duplicate URLs at the beginning of the line
Before:
https://en.wikipedia.org/wiki/Led_Zeppelin - Led Zeppelin - Stairway To Heaven 2
https://en.wikipedia.org/wiki/Led_Zeppelin - Led Zeppelin - Stairway To Heaven 1
https://en.wikipedia.org/...
1
vote
2
answers
81
views
How do I Write a RegEx that will Edit Only Very Specific Data
I'm trying to write a regular expression that will find data scattered throughout several files that look something like this:
[Something here](HTTP://somesite.com)
[DifferentStuff](HTTPS://Another....
1
vote
1
answer
269
views
Powershell rename-item using RegEx for filename irregular pattern
I have filenames in a directory that have different beginning strings of characters that I wish to strip out and leave just the alpha characters + file extension:
[example]
1-09. But Not for Me.mp3
1-...
0
votes
2
answers
180
views
RegEx Notepad++ Search and Extract
I am looking for the RegEx search string to extract a specific entry in a single row.
Example is
{"version":"264599-1-0","exportPath":"Site Management/Site Set-up/...
2
votes
2
answers
183
views
I want to get every command that has 3 letters and only three letters
I don't get the output I expect using apropos -k . |awk '/^.../ {print $1}' am I completely overthinking this? In this sample output only zsh should have come back.
I also tried this
apropos -k . | ...
0
votes
2
answers
83
views
Replace blocks of numbers: </2645>
I have a file in Notepad++ that was converted from a PDF.
I've managed to sanitise loads of nasty glitches with regex but this one escapes me.
Blocks of numbers like these:
</2478><2479>
&...
1
vote
1
answer
31
views
What is the purpose of the |$ within quotes in the following command?
openssl x509 -in cacert.pem -noout -text | grep -Ei ".*public.*|$" | less -Rx
How does this command filter the information in bold?
Technical College, CN = Jim's Root CA
**Subject Public ...
0
votes
1
answer
69
views
Delete all except matched items
I want to delete all the data except matched items from my file. I am using Notepad++
I want to keep everything between <w:t> and </w:t> tags delete rest of the matter.
Sample data:
<?...
0
votes
1
answer
378
views
Regex to find more than one occurrence in GrepWin
I want to find more than one occurrence of the tag h1 in multiples files.
The following regex brings files that has it more than 2 times, which is working great:
/(h1.*){2}/
However, what if I want ...
1
vote
1
answer
364
views
How to test if a cell matches given REGEX in LibreOffice Calc?
I have a cell, and I want to test if it passes a specific pattern: 3-4 alphanumeric, minus, 3-4 alphanumeric, minus, 4 digits, minus, 1 or more digits.
In other words, I want "TEST-TST-1234-33&...
0
votes
1
answer
61
views
How can I remove a fix substring from a UNIX/Linux output?
My question looks ridicilously simple, but:
I would like to remove an entire string, not a list of characters, so I can't use tr.
I don't know the position of my substring, so I can't use cut.
I'm ...
1
vote
1
answer
362
views
Use sed to "format" first two letters of every word
I am trying to get to a sed command to format (HTML) the first two letters of every word from a plaintext input. I would like to input a plain text and mark the first two letters bold with the <b&...
3
votes
4
answers
315
views
Select all lines of maximum 12 words that end that do not have any punctuation at the end
I want to select all lines of maximum 12 words that end that do not have any punctuation at the end.
Example:
Love's Equal On Earth
In a moving "in" and "out of focus" image, what ...
0
votes
4
answers
762
views
How do we search for files which contain a specific word and end in a specific file-type suffix?
How do we use Microsoft Windows PowerShell and Regular Expressions (Regex) in order to find all of the pictures (image files) on a computer such that the file name contains the word "dog".
...
2
votes
0
answers
57
views
How can I filter Windows 10/11 notifications based on string/regex?
I'm looking for a way to filter Windows 10/11 notifications based on their content, be it string match or even regex.
My current use case is that I'm in a Discord server which has a "firehose&...
1
vote
2
answers
63
views
How to isolate portion of string and remove excess in Notepad++ using regex?
I am attempting to isolate a particular section of a line, and delete everything else after it.
Below are some example strings on what the general formatting of the file looks like. Each one of these ...
-1
votes
3
answers
791
views
Notepad++ find and replace using wild card
I have this very long file with many lines like this:
MeshFile=brosm05028.gmt CollTarget=True HATTarget=True LODOut=(500.0)
What I am trying to do is to use notepad++ find and replace to set the ...
1
vote
1
answer
98
views
How to copy up to a particular character (including that character) in every line using Notepad++
I have a text file with about 10000 lines of text. The text file is in JSON format. I want to cut (& keep in clipboard) the data found after the ':' colon symbol.
{
"Cust_Data": {
"...
0
votes
1
answer
463
views
How can I combine "Search for multiple strings (patterns)" with "Print rows after a hit" in a string/search and output a common file?
I am using the windows version of grep "GNU Grep".
syntax: grep [OPTIONS] PATTERN [FILE...]
How can I combine different options with different patterns?
Both lines listed here work on their ...
1
vote
1
answer
184
views
Decline all URIs with tilde character in Nginx
I would like to return a 403 whenever a request contains a tilde character (~)
Example: https://example.com/~/item-1/ or even. https://example.com/item1?status=~pending
I want the above to return a ...
1
vote
1
answer
363
views
Combine two regex formulas into one (using notepad++)
Si cum îi semănau ! Fraţi buni, puindu-si, ca si el, tot sufletul
în ceea ce făceau, muncind din greu, luptind din greu, jert-
findu-se, fără nici un gînd de răsplată.
Simțind în tot ceasul,
...
1
vote
1
answer
344
views
How to remove all straight line shapes from a Microsoft Word document (*.docx)?
I have a docx document that has many straight line shapes in different parts of the document. I am tasked to remove all of them. I could do it manually but the document is 160 pages long and each page ...