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

learn more… | top users | synonyms (1)

8
votes
8answers
5k views

How do I copy file named starting with a dot?

I am trying to copy all files under directory A to directory B. All files under directory A are starting with dot, for example: A/.a A/.b A/.c which I found if I use: cp A/* B, always get error: ...
1
vote
2answers
46 views

Standardize \n and \r in Vim's search/replace syntax

In Vim, one searches for newlines as \n, but newlines in the replacement-string must be entered as \r. I understand that there are reasons for this behavior, but for my purposes I just find it ...
1
vote
3answers
1k views

Extract/delete all other text than whats inside “ ”, and after string

I'm have a very big data output in a .txt file that looks like this: value1="1",value2="2",value3="test3",value4="4" value1="1",value2="2",value3="anothertest3",value4="4" ...
1
vote
3answers
63 views

Can anyone explain why this pattern matching is not working using sed

Trying to print out specific times of logs based on recommendation from this thread from super user. I am not sure why my patterns are not being matched by sed. I have the sample date and time I am ...
-1
votes
1answer
50 views

Microsoft Word Wildcards

This is long, I hope I made it clear! Please ask if something is not explained correctly I have a document that has the word "The" capitalised in many places it shouldn't be. I wish to change "The" ...
1
vote
1answer
47 views

Matching only numbers that come in numerical order

I have numbers in [.] indicating the page number of an orginal printed document I am transcribing. However, the document also contains other numbers in [.] that do not correspond to page numbers. For ...
1
vote
1answer
17 views

How to remove characters from a matching string?

I want to remove spaces from a list of phone numbers. The phone numbers are in the following format: "+33 x xx xx xx xx" most of the time (quotes included). Spaces can be placed differently. In ...
2
votes
0answers
14 views

find using regexp and echo matches

I have about 50 users in /home/ directory and I have cloned a git repository to everyone: Executed at /home/ as root user: find . -maxdepth 1 -type d ! -name . -prune -exec git clone ...
1
vote
2answers
46 views

Replace all, “But” Regex Notepad++

I have a text file with lines looking like the one below : ('8510851205', 'needthishere', '', ''), I need it to remove everything and leave only needthishere on every single line. How would I do this ...
0
votes
0answers
21 views

Saltstack regular expression to target all except

I'm having trouble using regex with salt to target every minion except one. I have tried every example I can find and exhausted my limited understanding of Perl regex. I expect this to target every ...
0
votes
1answer
21 views

Notepad++ exclude starts with a two digit number

I would like to exclude anything that starts with 87. By combining the first two digits, I can find lines that start with ^8+7 or ^87. But I was trying to use ^[^8+7], but it doesn't seem to work. I ...
2
votes
1answer
22 views

Notepad++: Add tab at the beginning of a multi-line match found with regex?

I have text formatted like this: :AGG NUMBER 1 :TYPE Alfa any text 1 line 2 anythihng :END :AGG NUMBER 2 :TYPE char other any text 1 line 2 :END I need to add a tab character at the beginning of ...
1
vote
1answer
37 views

Notepad++ replace every 3rd and 4th iteration

I'm using notepad++ I'm wondering if it's possible to replace every 3rd and 4th iteration in lines of HTML. The original code looks like: <div class="ui-bar ui-bar-d" <div class="ui-bar ...
0
votes
0answers
18 views

Regular expression search of PDFs on Mac OSX

I need a PDF reader that will regular expression search across multiple PDFs contained within a folder. The search results should allow me to jump the to the position of each search result within each ...
0
votes
1answer
47 views

Find duplicate phrases - any tool or regex

I've got a long document, and I suspect that some phrases (one or multiple sentences) are identical or at least similiar. Is there some way to find these repetitive phrases? Some tool or regex?
-1
votes
2answers
33 views

Converting Perl Regex to PHP [closed]

I have the following Regex in PERL which I need to convert to PHP if($line =~ m/[<]div class="row.* id="(vm_[0-9]{8,9})"[>]/i){ } I currently have the following in PHP to match it, but I'm ...
4
votes
1answer
44 views

Replacing quotation marks in Word (reg ex)

I have a large text document with inconsistent quotation marks, i.e. ...Dolore magna aliquam “lorem ipsum” dolor sit amet, 'consectetuer adipiscing" elit, volutpat. Ut "wisi" enim... and I ...
-2
votes
1answer
36 views

Notepad++: How to remove text in between two specified strings using Regex

I have following lines of data: X1+0X2+0X3+0X4+0X5+0X6+0X7-0.25X8-0.25X9-0.25X10-0.25X11+0X12+0X13+0X14+0.8X15+0X16+0X17+0X18 ...
0
votes
1answer
28 views

In Vim, why does searching “/A\n\zsB” work, but not syntax highlighting “:syn match Statement 'A\n\zsB'”?

Assume the following text file: A B Or in other words, a file containing only the string A\nB. Let's see if I can match any B preceded by A and a newline. Simple enough. I can do this sucessfully ...
0
votes
1answer
38 views

Notepad++ regex highlighting

I'd like to be able to highlight entire lines in notepad++ by keywords, but these keywords would be added in the end of each line. I tried with the available mechanism of "User Defined Language" ...
0
votes
1answer
23 views

What regex pattern would I have to use to parse out unwanted characters in this format?

#!/usr/bin/perl POSIX qw(strftime); my $time = strftime("%YT%mT%d TTTT%H:%M", localtime); print ("Todays date and time is $time\n"); I am a little rusty at regex, what would be a pattern to search ...
-1
votes
3answers
77 views

How to replace all but specific part of string in Notepad++?

I have a list with lines like this: 103238704-|--|-INEEDTHIS-|-r4Vp5iL2VbM=-|-maiden name|-- Is there a way in Notepad++ to delete everything except INEEDTHIS? INEEDTHIS will be an email ...
0
votes
2answers
44 views

Remove the second literal \N per line in Notepad++

I have a text file with several hundred lines similar to below: Here are some examples lines,\Nthis text needs to strip out\Ncertain, Here are some examples lines. Here are some. Here are some ...
0
votes
1answer
23 views

Restrict grepping to non-comment lines

I need to find in Perl source files lines containing bin/exim|SendEmail|Unformatted except of comment lines (lines starting with # with possible whitespace before). I know how to do it with a ...
0
votes
1answer
24 views

Using the 'ed' editor, how can I print the first 20 matching lines?

Given a file of humongous size, I can edit with ed, then issue the following command. g/real/p Which will print out all lines containing 'real'. What I want to do is print the first 20. I know ...
1
vote
2answers
899 views

match all strings containing only one '/' character

I have a very long file containing file paths, one on each line. I would like to retrieve a list of all directories listed which are only 1-level deep. As such, I would like to extract only those ...
2
votes
2answers
5k views

Sed only print matched expression

How to make sed only print the matched expression? I want to rewrite strings like "Battery 0: Charging, 44%, charging" to "Battery: 44%". I tried the following: sed -n '/\([0-9]*%\)/c Battery: \1' ...
0
votes
1answer
2k views

RegEx to return string between 2 specific characters?

Can you please advise on how to return a string between 2 specific characters? Example http://sds.01/create/http/capital/870745800/create/period_1_1364871116_438861511.ssa I want to return : ...
0
votes
2answers
1k views

Why escaped single quote doesn't work in grep?

I am trying to match a string: * * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw with: crontab -l | grep '^[^#].*/usr/local/bin/growlnotify.*\-n \'myApp\'.*$' ...
0
votes
0answers
25 views

Looking for a solution to discover common text patterns in multiple strings

I'm looking for a solution where I can examine thousands of strings that share some similarity and have it discover appropriate regex pattern(s) that will give a 100% match on all strings? The catch ...
3
votes
2answers
595 views

Match exactly (and only) the pattern I specify in a grep command

Usually, grep searches for all lines containing a match for the pattern/parameter I specify. I would like to match just the pattern (i.e. not the whole line). So, if a file contains the lines: We ...
8
votes
4answers
2k views

Can I use perl regular expressions in the vim command line?

I want to use perl regular expressions on the vim command line. For example, to capitalize the words on the current line, you could type: :s/(\w+)/\u$1/g
2
votes
2answers
57 views

sed: How can I replace \r\r\n?

In this question on stackoverflow it is explained how one can replace a newline character using sed. My problem is that I want to replace the character sequence \r\r\n with sed. Can somebody help me ...
0
votes
1answer
32 views

Mark all URLs ending with .se (Notepad++)

I got a massive document with text. I want to mark all the URLs ending with .se I managed to mark the part of the url just before .se with \w+\.se. But some of these URLs got 3-4 subdomains. So if I ...
0
votes
1answer
39 views

How to Replace Words With VBScript Regex and VBA?

what is vbscript syntax for .net: \b[a-z]+\b Hi trying to replace all alpha words in the source. .net regex tester confirms this pattern will find all words: \b[a-z]+\b this: ...
1
vote
2answers
23 views

Find all php files which first or second line has more than N characters

I would like to find all php files on my server which first line or second line has more than N characters. I would like to print both the file name and the line content that was found. How would I ...
-2
votes
2answers
80 views

Remove all extra text before and after domain string per line in notepad++

I would like to take the following strings in and only keep the domains and <br> tags So: 390796,domain1.com,1,0,0,false<br> 390796,43domain2.org,2,0,0,false<br> ...
9
votes
5answers
2k views

Removing ANSI color codes from text stream

Examining the output from perl -e 'use Term::ANSIColor; print color "white"; print "ABC\n"; print color "reset";' in a text editor (e.g., vi) shows the following: ^[[37mABC ^[[0m How would one ...
1
vote
1answer
48 views

How to replace line in file with pattern with sed?

I'm reading a lot of documentation on sed, and am still stumped on my particular use case. I want to replace this line in a conf file with my own line: Replace this line: #maxmemory <bytes> ...
2
votes
3answers
7k views

notepad++ regexp to find all lines which contain a specific string

I am looking for a notepad++ regexp that contains a specific string. I then want to delete this whole line.
1
vote
3answers
12 views

End of line - add a pipe |

Can someone explain how at the end of each line I place a pipe with regex? Using find and replace in notepad ++ I'm trying to place content | Cheers!
1
vote
1answer
44 views

subtract a fixed amount from a number in an xml with find/replace in notepad++

It seems like I can't understand much of the notepad++ wiki, and I can't find similar question here. The problem: type="0" x="184" y="698" w="245" h="7" So I'm trying to add or subtract an amount ...
0
votes
1answer
17 views

How can I replace one Youtube URL pattern with another via FoxReplace?

Youtube changed its layout again. Now to get to a user’s uploads page you have to click on their nickname, then on the “Videos” tab, and then filter by uploads-only from a dropdwon menu. If you also ...
10
votes
5answers
10k views

use of alternation “|” in sed's regex

I am using sed, GNU sed version 4.2.1. I want to use the alternation "|" symbol in a subexpression. For example : echo "blia blib bou blf" | sed 's/bl\(ia|f\)//g' should return " blib bou " but ...
14
votes
5answers
529 views

Match and delete in Notepad++

I have the following text in Notepad++. 192.168.0.1 37 ms N/A 192.168.0.2 Dead N/S 192.168.0.3 ...
3
votes
2answers
126 views

How to comment out multiple line matching a regex using sed or awk

I have a file that contains this: [...] location /static { ... multiple lines ... } [...] location /static/ { ... multiple lines ... } [...] And I want to get: [...] # ...
6
votes
2answers
3k views

Firefox3.5 addon for Regular Expression Search?

I've tried to look for an add-on with Firefox 3.5 which enables me to look up web page content against regex. I didn't find anything that helps, how about you? The version that I am using is Firefox ...
1
vote
1answer
50 views

Find & Replace in notepad++ with regex

I need to convert some old VB.net code to c#, and to speed things up I was planning to use regex. For instance, in this piece of code: if (Request.ServerVariables("SERVER_NAME").StartsWith("user")) ...
1
vote
1answer
22 views

Is it possible to sed -i from a text file to another text file?

I'm coding a shell script on my Debian box and there's a line on the script that needs to delete some emails from a textfile that is full of emails, like this: sed -i ...
-3
votes
1answer
42 views

Does Notepad2 have a multiline mode for regex find/replace?

Completely rewriting this question since I've discovered the tru source of the problem. I have the following text file: strUpdateSql.Append(" this is a string ,") strUpdateSql.Append(" that has ...