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)

3
votes
3answers
485 views

Using vim to delete all lines except those that match an arbitrary set of strings

I use vim to remove all lines except those that match a particular string, e.g. :g!/[string that I want to remain in the editor]/d Works great. But what I really want, and haven't found anywhere, ...
0
votes
0answers
50 views

How to define new scopes using arbitrary delimiters in Sublime Text 2

TL;DR: How do I bring Ruby-like comment scope to plaintext files for sublime text? I want to customize my plaintext file look in ST2 by allowing comments. So far I have managed to extend the ...
0
votes
0answers
66 views

Can I apply a regex to file filter on Notepad++?

I have a folder full of xml files, and I want to search through them for a particular ID. However, I only want to search the files that are of the format hello_apple_01.xml, hello_apple_02.xml... ...
1
vote
2answers
381 views

Remove quotation marks around a number (while leaving other quotes)

I want to replace all text like this: "latitude": "32.336533", with this: "latitude": 32.336533, I'm using Notepad++.
0
votes
0answers
41 views

How to identify tab delimited columns in Multitail

I'm trying to remove certain columns from my logs, where columns are delimited by tabs. Here are some ways I've tried to remove the second column which didn't work. multitail -kc " " 2 my.log ...
9
votes
2answers
11k views

How to find and replace the character “*” in excel

I am trying to find and replace the * (star, or shift+8) character in a bunch of formulas in Excel 2007. * of course matches the ENTIRE contents of the cell, which is not what I want. How do I ...
0
votes
2answers
56 views

Multiple exclusion patterns with grep

I would like to select lines which do not match the specified pattern, where I have multiple patterns to exclude. As an example, I want to exclude lines which start with the keywords apple and banana: ...
3
votes
1answer
2k views

Microsoft Office Word 2010: How to “Find and Replace” an entire line using “regular expressions” (wildcards)?

I would like to "Find and Replace" entire lines in Microsoft Office Word 2010 which match some criteria. I tried to find the solution in the official documentation, but I didn't find the answer: ...
0
votes
1answer
40 views

Redirect domain name

I have two domain names pointing to my server. I want them both to serve identical HTML. I thought I would just do the following, however, it was unsuccessful. Note that I eventually will want ssl ...
0
votes
2answers
93 views

Removing Nested LaTeX Tags with Regex

How would I use regex (such as with sed) to remove all \index tags that occur inside any \index tags? For example, a nested mess like this: \index{Test\index{test\index{test}}ing One\index{one} ...
2
votes
1answer
273 views

Use perl to do multi-line replacement [closed]

I have to do some replacements in many *.c files. I want to do the replacement like this: original: printf("This is a string! %d %d\n", 1, 2); result: print_record("This is a string! %d %d", 1, 2); ...
1
vote
2answers
118 views

Microsoft Word 2010 regex replace

I am having a problem with a regex find and replace in Word 2010 (Windows 7). I want to convert reference citation numbers in parentheses to the same numbers in brackets. For example, (20-23) should ...
10
votes
9answers
7k 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: ...
2
votes
1answer
71 views

find -regex not recognizing \d digit

I have a directory structure that looks like the following: processor0/10 processor0/10.1 processor0/10.2 processor1/10 processor1/10.1 processor1/10.2 ...etc... processor7/10 processor7/10.1 ...
1
vote
1answer
379 views

How to use REGEX to capitalise the first letter of each word in a sentence?

I would like to use regular expressions (REGEX) to capitalise the first letter of each word in a sentence. I have achieved the same result in programming languages, but it seems that using regular ...
0
votes
3answers
69 views

egrep for time in H:MM:SS format

Working on the file an need to grep the line with a time stamp in the H:MM:SS format. I tried the following egrep '[0-9]\:[0-9]\:[0-9]'. Didn't work for me. What am i doing wrong in regex?
2
votes
1answer
61 views

Regular expression that finds same words within 'n' words of each other

I'm trying to put together a regular expression search that finds any two (or more) words that are within n (e.g., more than 1, less than 5) words of each other. The goal is to search over a prose ...
0
votes
0answers
97 views

Apache mod rewrite testing tool (no online tools)

I've tested some great RegEx standalone tools and found a couple of mod rewrite online tools, but is there some standalone tools for testing apache mod rewrite definitions? Ideally, I want something ...
0
votes
1answer
102 views

Vim experts: how to find a number within a range based on two numbers? Eg “777” matches “667:888”

I need to search for numbers in a text with Vim. The numbers I need to find are often within a range based on two numbers and I need to match that range based on a single number. For example, in my ...
1
vote
3answers
89 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
106 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
vote
1answer
51 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
61 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 ...
1
vote
2answers
88 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
1answer
147 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
104 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 ...
0
votes
1answer
180 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
50 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
81 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
462 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
45 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
310 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
40 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
284 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
88 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
26 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
26 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
1k 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
6k 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
6k 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
0answers
26 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
698 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 ...
9
votes
4answers
3k 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
238 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
324 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
73 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
390 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> ...
1
vote
1answer
675 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> ...
1
vote
3answers
75 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
202 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 ...