Questions tagged [regex]

Also known as regular expression or regexp, a description of a set of strings, often used for searching and validating strings.

Filter by
Sorted by
Tagged with
2 votes
1 answer
4k views

How do I inverse my selection in "find and replace"?

%%& BUNCH OF TEXT &%%ASDA WR ASDAR ASDSETSF ASDSADGSRT %%& EVEN MORE TEXT &%% aSDAER ASD %%&TEXT HERE TOO &%% I'm trying to remove all of the junk text between the "&%%" ...
Mason's user avatar
  • 23
2 votes
1 answer
93 views

make \w match characters like ÄÖÜäöüß?

Is it possible to customize the behavior of regex metacharacters for character classes like that? (In Sublime, or more generally.)
Owen_AR's user avatar
  • 412
2 votes
1 answer
4k views

Parsing multi-line string to extract only matched lines

I have a multi-line string and I'd like to only extract lines that match a certain pattern and discard the rest of the string. Original string: lorem ipsum dolor sit amet consectetur nunc KEEP THIS ...
smaxey's user avatar
  • 83
2 votes
1 answer
709 views

About regexp in emacs ediff-directories

I want to compare two directories which have similar hierarchy. With "M-x ediff-directories" within Emacs, I was prompted to input a regexp to constrain the name of files I want to compare. For ...
hero2008's user avatar
  • 627
2 votes
1 answer
642 views

Using Notepad++ to search/replace PHP code with regular expressions

I would like to update some PHP code into the Joomla framework, replacing things like: $myvar=$_POST["myvar"]; with $myvar=JRequest::getVar('myvar'); This seems like it should be easy enough but ...
Don's user avatar
  • 21
2 votes
0 answers
660 views

Changing puttyTRAY's URL regex in order to match URLs across lines separated by tmux window boundaries

I use puttytray to access a shell account on which I have a tmux instance running. Inside tmux, I have irssi running in a window. When people post long URLs in IRC, however, it's annoying since these ...
ventolin's user avatar
  • 121
2 votes
3 answers
6k views

How to use cygwin (or linux command) to rename the files and directories recursively with regular expression

I am using Windows, and trying to use Cygwin to perform this task. I would like to rename the files and directories recursively as following: From: 1010110010\ 1010110010\1010110010.jpg 1010110010\...
Allen's user avatar
  • 399
2 votes
2 answers
1k views

RegEx is matching characters before I want it to

I need to parse a string that looks like this: A Christmas Special - Special of the day into 3 or 4 distinctive groups depending on if the - character is present in the original string or not like ...
KAnders's user avatar
  • 23
1 vote
3 answers
245 views

How to remove text from vim

I want to remove all the words that ending with abc Example: 111abc 222def 333abc 444def 555abc 666def From here I want to delete all the words that ending with abc. so I tried this :s/abc//...
max's user avatar
  • 3,943
1 vote
2 answers
4k views

vim submatch - trying to put quotes around a string

I'm trying to use the vim submatch command to put quotes around all strings of characters in a line of text, and it doesnt work. Here's what I'm doing :s:\a*\a:\(submatch(0)\):g All it does is ...
MYV's user avatar
  • 1,183
1 vote
6 answers
4k views

UNIX "find" command, match literal "dot"

I need files ending with ".pdf" or ".png"; here's my attempt: find /Users/robottinosino/Desktop/_PublishMe_ -type f -regex '.*[pdf|png]' this incorrectly includes files ending with "Apdf", "Zpdf", ...
Robottinosino's user avatar
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 ...
boardrider's user avatar
  • 1,143
1 vote
1 answer
28k views

Extract substring before = sign using awk

Say I have some file with a bunch of lines in the form someString=someMoreCharacters anotherString.blah=foo=bar blah.blah.blah=foo.bar.=foobar Desired output someString anotherString.blah blah.blah....
well actually's user avatar
1 vote
2 answers
2k views

Notepad++ replace last octet (?) from IP adresses with a 0

Sorry guys for a very simple question, but I couldn't find the correct way to replace the last octet (is this the correct word for it) with a "0". So far I tried several things, after searching these ...
Joanne's user avatar
  • 223
1 vote
2 answers
894 views

'Grep'ing the IP out of a finger command on linux

I am using ssh to access another machine and require the IP from which I am sshing from. Finger gives this, but I don't know how to isolate this from the information given. So far I have: finger | ...
Jonno_FTW's user avatar
  • 1,570
1 vote
2 answers
2k views

VIM Regex replacing words

Which regex do I have to use in VIM to replace all words 'to' from a text with the word 'foo'? (I don't want to replace 'to' when it happens in a word like 'together').
Christian's user avatar
  • 2,264
1 vote
1 answer
4k views

How can I use Powershell to rename all files where the name has the format "digits [space] name with spaces" to "digits [hyphen] name with spaces"?

I have a lot of files with names of the format "digits [space] name with spaces" or "(digits) [space] name with spaces" e.g.: 23 Filename 23 with spaces.txt (47) Filename 47 with ...
ChrisF's user avatar
  • 41.3k
1 vote
2 answers
156 views

Notepad++: Regex issue

What I'm trying to do is to remove all line numbers. In other words to find and replace all expressions like x: or xx: with : Tried: No success! Also No success! Any suggestions? Thanks in advance!...
Tural Ali's user avatar
  • 1,943
1 vote
1 answer
6k views

How do I use regular expressions in TextMate's find dialog box to search and replace?

I want to replace all the \caption(.1..) \caption(.2.) \caption(.3..) \caption(.4..) by \caption{} What should I put in the search box?
epsilon8's user avatar
  • 730
1 vote
4 answers
2k views

using sed to remove lines in a file

I have a file that looks something like this: Heading - - Completed foo - More information - Still more * Need to complete bar - Did baz (comment blah blah) *** Another - * Need to ...
eleven81's user avatar
  • 15.6k
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: ...
Frank's user avatar
  • 57
1 vote
2 answers
1k views

How to remove $ sign and comma(s) from within parentheses

I have 1000s of lines of varying text. Within most lines, there exists a set(s) of dollar values within parentheses. I would like to remove the leading “$” sign and comma(s) within those ...
mapman's user avatar
  • 93
1 vote
1 answer
14k views

Regex: Select all the words/strings that begins with .dot

I want to select with regex all the words that begins with .dot for example: .myself or .I go home or .5 a clock Can you help me?
Just Me's user avatar
  • 846
1 vote
1 answer
415 views

Notepad++ merge all lines that do not begin with a date

I have .csv file in Notepad++ that contains data like this: 1-6-2018,"(101)","","Sale",-862.96,, "(Sale)",,837.96, ,"Diesel",12.000 Ltr,69.83/Ltr,837.96, "Sales @ 5%",,23.80, ,"Polishing Cloth",1 ...
Norman's user avatar
  • 559
1 vote
4 answers
1k views

Regex is matching all combinations

I have the following text below. How do I write the regex to capture all text related to REQ_XXX? This is my expression .*(REQ_.*)\|, but it captures |3 |4 |5. I just want it to stop after the first |...
GoChanGo's user avatar
1 vote
1 answer
3k views

Trying to remove commented lines from code with no luck

Trying to remove all commented lines from code with sed: 1) /* ... */ and /* \n \n \n */ Tried using this structure to hide showing what is inside sed -n '/^\/\*/,/\*\//!p' But it appears to hide ...
anaheimjogger's user avatar
1 vote
3 answers
13k views

Notepad++ Merge 10+ lines into 1 line

I'm trying to use Notepad++ to merge multiple lines into one. The problem I'm facing is when trying this code, I get this result: Date/Time: Sequence: Event: Category: Priority: Attention: Alert: ...
pau13z's user avatar
  • 11
1 vote
2 answers
29k views

Notepad++: How to remove text after second occurrence of comma using Regex

I've got text lines like string1,email,string2,string3 How can I use regex to return the following? string1,email I want to remove everything that comes after the 2nd comma.
Samuel's user avatar
  • 13
1 vote
1 answer
3k views

How do I select a range of lines until I reach a line containing specific words?

How do I select a range of lines until I reach a line containing specific words? For example, start at line 1 and select every line until you get to a line with the words: hello world
Trinity's user avatar
  • 21
1 vote
2 answers
17k views

Delete several directories with a common prefix at the command prompt

I want to delete several subdirectories of the same directory. The directories have "tmp" as the first three characters in their name. This is not working: C:\Documents and Settings\rajesh\Local ...
HOLYBIBLETHE's user avatar
1 vote
2 answers
104 views

Trying to get `$FOO =~ bar|baz` to work in Bash and Zsh

I'm trying to get a simple if statement working in both Zsh and Bash but I can't find something to work with both. # this works with Zsh if [[ "$TERM_PROGRAM" =~ iTerm\|Apple_Terminal ]]; then echo ...
twe4ked's user avatar
  • 136
1 vote
2 answers
7k views

Notepad++/Regular Expression to find line with same beginning, different ending

So, I've read a bit and found NotePad++ doesn't use "normal" regex (starting to think I'll just go back to SciTE), but here's my question: I've got an exported list of data with some redundant data ...
music2myear's user avatar
  • 41.7k
1 vote
1 answer
550 views

How to replace text using regex with back-referece in Notepad++?

I'm converting Windows batch script .bat to Linux batch script .sh What takes time a lot is to change the way .bat script use variables. i.e. In Windows @set varName=122 echo %varName% In Linux ...
Nam G VU's user avatar
  • 12.3k
1 vote
2 answers
3k views

Excluding paths in grep

I can't seem to find any documentation dealing with this: is there any way to stop grep from printing the path to the file of a matched line when searching over multiple files?
SegFaults McGee's user avatar
1 vote
4 answers
326 views

my sed expression does not work

I want to use sed to comment out a certain command in a js file. The command is called processLoad(..). I came up with expression below but it doesn't do what I expect it to do. The computer that I ...
dr jerry's user avatar
  • 189
1 vote
2 answers
2k views

Mass renaming files, removing dots

I want to rename files as to delete unneccessary dots. ie: File.something.jpg -> Filesomething.jpg I.Have.Too.Many.Dots.png -> IHaveTooManyDots.png How can this be done? find -name *.*.* lists ...
Robus's user avatar
  • 254
1 vote
3 answers
2k views

What is the easiest way to do PCRE-style regexp search/replace for MS Word?

You can do this by cut+paste to another RTF editor that supports them, but this does all kinds of horrid things if you want to reimport the text, like mess up tracked changes. Is there something like ...
Charles Stewart's user avatar
1 vote
1 answer
416 views

Notepad++ move first two characters to end of line

I have a list of Country Codes in the following format: US:United States I'm trying to replace it with United States:US I've moved the semi-colon to the end by searching for ^(.*)\b:\b(.*)$ and ...
Junky's user avatar
  • 145
1 vote
2 answers
1k views

Regex: Find all links that doesn't have one / (slash)

Suppose I have a link like this: https://neculaifantanaru.com/en/the-continuity-of-the-work-of-art.html How can I find all links (such as the one above) that doesn't have / (slash) after /en The ...
Just Me's user avatar
  • 846
1 vote
2 answers
150 views

Capitalize everything before a Symbol

I need to find a possibility of capitalize every word BEFORE a symbol. Example: bla apple banana=Bla apple banana Result: Bla Apple Banana=Bla apple banana I want to Capitalize every first letter of ...
emjay3256's user avatar
1 vote
3 answers
1k views

How can I extract the names of games of which I added shortcuts to Steam from a shortcuts.vdf file?

I am trying to put together an excel sheet that lists all the games that I have added shortcuts to Steam. Steam lets you add shortcuts to non-steam games and acts as a launcher for them. The shortcut ...
Phil's user avatar
  • 94
1 vote
2 answers
371 views

Regex: Change the order of the lines from the last one to first one (multiple files)

I have this lines (sentences) that must be changed in the opposite direction, from 40 to 1 (and vice versa) (into 125 files, that is why I need a regex solution) for multiple files. 1. I go home. 2. ...
Just Me's user avatar
  • 846
1 vote
3 answers
3k views

Unable to use multiple -replace statements with PowerShell

I've been trying to achieve a more consistent file naming scheme and chose PowerShell to help with the task. However, for some reason I can't get the script to replace multiple patterns with ...
gargoylebident's user avatar
1 vote
1 answer
34 views

Why is my regex code not returning any result?

Here is my code: import re word="ABCD 12345" match=re.search(r"\d*",word) print(match.group()) For this code, I am getting no output (no errors as well). Kindly help. What is the issue here?
Prathvi Singh's user avatar
1 vote
3 answers
2k views

Notepad++ and XML - Replace and capitalize the first letter of all words in a tag element

I have an XML file with the following structure: <id>1</id> <name>alligator and stingray</name> ... <id>99999</id> <name>dolphin with carp</name> I ...
Tần Quảng's user avatar
1 vote
2 answers
2k views

Extract portion of text file from first occurrence of one string to first occurrence of another

How can I extract a portion of a large text file, starting at the first occurrence of FOO and ending at the first occurrence of BAR? In my case, I'm trying to extract a portion of a sql file created ...
dmgig's user avatar
  • 177
1 vote
2 answers
3k views

(Notepad++) How to replace a text that has certain word in that line?

I have multiple lines like this: { "source": "Source A", "target": "Source B", "idTarget": "3,345", "strength": "0.5", "value": "633.5138" } { "source": "Source C", "target": "Source D", "idTarget": "...
deathlock's user avatar
  • 323
1 vote
3 answers
87 views

Match VAR_NAME but not $(VAR_NAME)

How can I match VAR_NAME but omit $(VAR_NAME) at the same time using grep or egrep? The best attempt so far has been egrep -nH '*[^(]VAR_NAME' $i But this doesn't match the case when the line starts ...
iksemyonov's user avatar
1 vote
2 answers
2k views

Converting C# Regex To PowerShell

Our Software department has a program that runs SQL scripts from a certain folder. I now need to replicate this functionality in PowerShell. C#: var commands = Regex.Split(sqlFileText, @"^\s*GO\s*$",...
Deadly-Bagel's user avatar
1 vote
2 answers
4k views

how to match similar domains in adblock custom filtering

I am accessing a website which gradually increments its domain name: http://mywebsite100.com/ then http://mywebsite101.com/ and so on... I wrote a rule to block ads on all upcoming domain names ...
afterburner's user avatar

1
11 12
13
14 15
42