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)

2
votes
1answer
14 views

Treat part of a Regex expression as non-special characters

Let's say I've got a regex expression utilizing some of the special chars, but also a portion with 'normal' text that just happens to have some symbols in. Let's also say I'm too lazy to start ...
1
vote
2answers
35 views

Best way to increment numbers in one line in Linux

I have one line with lot of entries among which is also time. ('DEFAULT',17,NULL,'2014-07-14 10:30:00','Something','2014-07-14 06:30:00',1),('DEFAULT',26,NULL,'2014-07-14 ...
1
vote
2answers
32 views

Regex in LibreOffice Writer - finding “everything” but one thing

I have a text (html code) and need to find <p> tags with their classes, id, styles (if any) etc. I'm doing this using the following regexs: <p(.*?)> or (<p([^>]+))> The pattern ...
0
votes
0answers
18 views

Notepad++ illegal XML character target search using Regex

Fellow Forum Members, I am using the latest version of NotePad++ and I have done a search for illegal XML symbols such as "&", ">", "<", "©" among 200 separate XML files. I found a couple of ...
11
votes
8answers
9k views

Notepad++ - Removing the first column in a comma separated file

I have a large CSV file that I need to remove the first column of data. I cannot open it in Excel because Excel converts some of the values in the columns to scientific numbers. I am using Notepad++, ...
3
votes
1answer
128 views

Notepad++ - Merge all lines into one and add separator

So this is my situation: I have a lot of lines like this: line1 line2 line3 line4 And they all start with different spaces. What I want to do is merge all the lines in the ...
3
votes
1answer
22 views

Microsoft Word Wildcards to Find Any Dates of a certain form

I am editing a very large document (~200 pages), with multiple dates on each page. I am looking to use MS Word's wildcard function in the find-and-replace feature to remove these. Some examples of ...
0
votes
2answers
26 views

How to construct a regex find/replace in word 2010

I have some limited experience with basic javascript regex, which I've used to manipulate some user data entries. But now, I've been asked about manipulating MS Word 2010 documents. Specifically, my ...
1
vote
3answers
1k views

Fink remove all packages

I switched to HomeBrew from Fink, and I want to uninstall Fink and all of the packages I installed with it to avoid problems in the future. I found this perl snippet that should remove all pacages, ...
11
votes
6answers
43k views

Matching only the first occurrence in a line with Regex

I am completely new to regex and I would greatly appreciate any help. The task is simple. I have a CSV file with records that read like this: 12345,67890,12345,67890 12345,67890,12345,67890 ...
13
votes
4answers
9k views

Newlines in sed on Mac OS X

I find that \n doesn't work in sed under Mac OS X. Specifically, say I want to break the words separated by a single space into lines: # input foo bar I use, echo "foo bar" | sed 's/ /\n/' But ...
0
votes
2answers
219 views

Find repeated words in a text

One of most common typos is to repeat the same word twice, as as here. I need an automatic procedure to remove all the repeated words in a text file. This should not be a strange feature for a modern ...
2
votes
3answers
5k views

Extract/delete all other text than whats inside quotation marks (“ ”), 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" ...
0
votes
0answers
12 views

OS X Numbers Find and Replace With Variables

I have a massive spreadsheet and a column has a load of HTML in it and i've spotted an error in the code so I need to update it. Each cell with the code in has a bunch of HTML, heres what the error ...
1
vote
1answer
44 views

How do I edit an xmlTV file using sed (or a similar tool)?

I have an xmlTV file that looks like this: <channel id="10125.dvb.guide" <!-- number="62" type="0x1" flags="0xf" bouquet="4097" region="4a" sid="10125" -->> <display-name>ITV ...
0
votes
1answer
16 views

Modify terminal STDOUT/STDERR to change the line colour based on a REGEX

Is this possible? What I would like to achieve is when running unit tests (Python) to highlight any line which matches the path to the current project directory and leave other output untouched. ...
2
votes
1answer
42 views

How to search for special characters in Sublime Text 3

I have a few lines starting with the character # and I search for it in SublimeText 3, but ST3 said unable to find \b#\b. I then tried to search \# and it also fails (with regular expression mode ...
0
votes
1answer
39 views

BASH : grep count same word occurrence

Is it possible to count the maximum number of occurrences of a word in a string using only grep ? Here is an example of what I want : script.sh "aaaa bbbb ccc bbbb azesd bbbb" would return bbbb ...
4
votes
2answers
2k views

Can Outlook Search use Regular Expressions (or wild cards)?

I'd like to search my Outlook email with regular expressions. Is this possible? If not, is there any sort of non-regex wildcard functionality? Without any sort of plug-in is preferable, but if not, ...
1
vote
2answers
70 views

Notepad++ Find and Replace: Wildcard Varying Number of Lines?

I have a tricky problem. I need to make a minor change to a large number of xml files (500+). The change involves switching a value from 'false' to 'true.' The line that needs to change looks like ...
1
vote
1answer
21 views

MS Word regex insert carriage return in match

It appears that MS Word accepts regular expressions for finding and replacing strings. I would like to use regex to add carriage returns to a block of text, in order to parse out individual lines. ...
-1
votes
1answer
23 views

Backslash expression to add an underscore at the end of a word?

I have a huge list of words where every one is in a new line. I'm currently using the text editor SciTE which can perform backslash expressions. Which expression do I need to use to add a _ ...
0
votes
1answer
76 views

Exclude a single file from an nginx location match

I have a location on nginx like this: location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ { return 403; error_page 403 /403_error.html; } I have a php script that combines ...
0
votes
1answer
21 views

Partial formatting in Microsoft Word find and replace

I want to use Word's "Advanced Find and Replace" tool to find this string: See, e.g., And replace it with this: See, e.g., The difference between the two strings is that the second comma ...
10
votes
4answers
30k views

Can you do Regular Expressions in Excel without VBScript?

I'm looking for an Excel function that I can put in a cell to do a regex search of the contents of another cell. Is there anything available to do this? I'd prefer not to have to add VB Script to ...
0
votes
1answer
23 views

vim regex :s/^\s*\(.\)\+/\\\1/g only shows last character substituted

I need to prepend a backslash \ to each character in a string, excluding any leading whitespace. I believed the following would do the trick. :s/^\s*\(.\)\+/\\\1/g but it produces this result for ...
2
votes
3answers
139 views

How should I write a regex to match a specific word?

I've been trying to get a specific regex working but I can't get it to do what I need. Basically, I want it to look for ROCKET. The regex should match ROCKET in upper or lower cases, and with or ...
0
votes
1answer
50 views

Notepad++ find procedure/ function declaration

I need to find a procedure declaration in Notepad++. How should I search using regex to find procedure someproc(..) and not the procedure "includes" external procedure someproc(...) i.e., search ...
0
votes
1answer
25 views

Concatenating varying number of lines notepad++

I have a file where i need to take varying number of lines and concatenate into one. It could be two, three, or four lines that require concatenation. There is a common set of characters (say 'xxx') ...
2
votes
1answer
66 views

Getting RegEx Code for File Name Change

Good Day Please help to find the right RegEx or other code for changing file name. Many subtitle files I have unnecessary character. I need to rename in my expectation format. Here the example Raw ...
1
vote
1answer
18 views

Using Perl regex over multiple lines

I'd like to replace all occurrences of this in a file: ab ba With this: a a I tried the obvious: $ perl -i -p -e 's/ab\nba/a a/' file.txt With no success. How is this done? I can't find any ...
14
votes
8answers
43k views

What regular expression can I use to match an IP address?

With the following grep syntax I want to match all IP address in a file (from a ksh script) grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' file The problem: It also matches words ...
2
votes
2answers
73 views

How to recursivly delete all JPG files, but keep the ones containing “sample”

How can I find and delete all the .jpg files in a directory tree with the exception of the ones containing "sample" in their filename? For example : a.zip -> keep it b.jpg ...
0
votes
2answers
2k views

Bash: exact match of a string with regex

I have to do an exact match on a string with a regex. i have to realize this pattern: toCheck must start with 2 occurrence of $str1, with max 1 occurrence of $str2. If toCheck match the pattern, i ...
2
votes
1answer
111 views

How to capture a couple of lines around a regex match?

I am searching for a regex expression to match couple of lines over the matched line. For example: ABCDEFGHADEFGH ABCDEFGHADEFGH ABCDEFGHDEFGHABCDEFGH ABCDEFGHDEFGHABCDEFGH ABCDEFGHABCDEFGHABCDEFGH ...
1
vote
1answer
15 views

Grep Whitespace across multiple lines

Given the following in a bunch of text files (.vb): Partial Class [A-Za-z0-9_] Inherits System.Web.UI.Page End Class I'm trying to grep for files that have this basically empty code file, to ...
1
vote
2answers
62 views

Delete n lines following a pattern (and the line matching the pattern)

How can I delete a line containing a matching pattern and the following n lines using a tool supporting regular expressions? Said differently, how can I write a regular expression matching a line ...
1
vote
2answers
30 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 ...
0
votes
1answer
72 views

Delete all script code when saving an HTML file

I save and archive a lot of Paypal receipts, and the files come with tons of garbage script code not necessary for archival purposes. I would like to come up with a way to strip all that code so I ...
0
votes
3answers
32 views

What does `[]` do in a regex?

This webpage contains a number of regexes containing []: http://mmcif.wwpdb.org/dictionaries/ascii/mmcif_pdbx_v40.dic An example: [][_,.;:"&<>()/\{}'`~!@#$%A-Za-z0-9*|+-]* The page ...
1
vote
2answers
44 views

Regex to select only specific number of spaces

I am using notepad++ and I want to do a find & replace operation. For example 4 number of spaces means 1 tab 6 number of spaces means 2 tabs etc. In my file all the spaces are in the ...
2
votes
2answers
43 views

How do I signify repetition in a ZMV regex?

I'm trying to manually pull the digests off of Rails assets (don't ask). I was directed to ZMV for easy regex-based find/replace. But the normal {32} syntax for specifying an amount of repetition does ...
0
votes
1answer
18 views

Using grep for text search

I need to search the filesystem for text strings that match some string. I'm trying to get where the commands are used, meaning in which files they are called or used. I need to find every file where ...
0
votes
1answer
39 views

Is there a way to highlight text matching a regular expression in Chrome even upon page redirection?

Is there a way to highlight all words that are written in ALL CAPS when I load certain pages in Chrome? Ideally, the solution would work for the current page, and when I click the form button, it ...
0
votes
2answers
30 views

Append text to lines between two patterns every time they appear in a file

This will be a rather hard one, i guess. I have to fiddle around with inline documentation that is extracted into html files to be used as online documentation, but these parts of the files should be ...
0
votes
1answer
30 views

RegEx expression to replace /randomword/ with <i>randomword</i>?

I'm looking for a RegEx expression to use with Find & Replace that will turn /randomword/ into <i>randomword</i> without actually changing the random word. Possible to do this ...
-1
votes
2answers
114 views

Replace any number of spaces using regular expressions

How can I replace any number of consecutive spaces, with, for example, a tab in a text editor supporting regular expressions (like Notepad++) To clarify: Replacing every occurrence of one or more ...
1
vote
2answers
40 views

Remove lines containing only a word and a number ? (notepad++, regex)

I have several hundreds of .txt files from which I would like to remove the lines where only the word "Volume" followed by a number appears. The word "Volume" may appear several times in each text ...
1
vote
0answers
35 views

how to set outline-minor-mode heading levels in outline-regexp

I am trying to add a custom heading to program mode, and I want it to be on the highest level and move all other levels down, so I can add more structure to my long script. For example, for python ...
20
votes
4answers
4k views

Substitution in text file **without** regular expressions

I need to substitute some text inside a text file with a replacement. Usually I would do something like sed -i 's/text/replacement/g' path/to/the/file The problem is that both text and replacement ...