Questions tagged [regex]
Also known as regular expression or regexp, a description of a set of strings, often used for searching and validating strings.
109
questions
10
votes
1
answer
29k
views
Perl for matching with regular expressions in Terminal?
I'm trying to familiarize myself a little with Perl to use for regular expression searches in Terminal (Mac). Now, I'm not really looking to learn Perl rigourously, just trying to find out how to do ...
190
votes
18
answers
157k
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 ...
25
votes
5
answers
82k
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 ...
40
votes
2
answers
74k
views
Is there a way to search for a pattern in a MS Word document?
Is there a way to look up patterns inside an MS Word document instead of an exact match?
I have a document where all decimals have been written as / instead of .. For example, 1.02 has been written ...
5
votes
6
answers
6k
views
Editor with muti-line search and replace
I am looking for text editor for Windows which is capable of performing search and replace operation of multi-line text block.
It should be able to run this operation on a folder or currently opened ...
98
votes
8
answers
90k
views
How can I search for regular expressions within webpages using Google Chrome or IE?
How can I search for regular expressions like 'foo|bar' on webpages using Google Chrome or IE? I'm aware of the "Regular Expression Searcher" extension, but it does not work for me. (Nothing happens ...
65
votes
7
answers
66k
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 the ...
59
votes
11
answers
46k
views
Renaming many files in Mac OS X, batch processing
I used to rename file in Linux via a rename command:
rename 's/old_pattern/new_pattern/g' *glob
Is there something similar in Mac OS X (Snow Leopard)?
33
votes
3
answers
161k
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>
...
25
votes
9
answers
91k
views
Regex Replace from Command line
Is it possible to regex replace from command line? Right now I'm using notepad++ to do this. In command line I can only use FINDSTR wich can only locate the mached files/lines
EDIT : Maybe it will be ...
12
votes
2
answers
31k
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, ...
0
votes
2
answers
1k
views
Use multiple conditions in find regex in shell
EDITED:
I need to use -E for extended regex.
I have a folder with this files (just an example):
I'm trying to find all files that:
Start and end with #. (e.g #hi.h#)
End with ~. (e.g file.txt~)
I ...
235
votes
3
answers
125k
views
How to delete all lines that do NOT contain a certain word in Vim?
In vim I can delete all lines that contain the word "price" with this
:g /price/d
How can I delete all lines that do NOT contain the word "price"?
23
votes
4
answers
63k
views
Notepad++ split line after given number of characters
Is there a way in notepad++, to split one line text, to text with given maximum number of characters in one line? I found only undefined line split in lines operations.
23
votes
4
answers
117k
views
Find and Replace text between ^ and ~ in Notepad++
I have a large text file where I want to remove all text between the ^ symbol and the ~ symbol. This needs to work across lines as well.
I tried doing a regular Find and Replace using ^*~ in the Find ...
23
votes
2
answers
24k
views
Howto search in PDFs using regular expressions? [closed]
Usually I use Notepad++ to search in file(s) using regular expressions. Today I am wondering if there is a PDF program that does the same for PDFs. Of course I could convert the PDF to text and use ...
22
votes
5
answers
9k
views
Is there software to allow me to search a PDF file with Regex? [closed]
I would like a PDF viewer that I can search documents with using regular expressions. Is there such a thing? I've tried PowerGrep, but it doesn't have a graphical viewer and its interface is a little ...
13
votes
1
answer
27k
views
Regex for "or" of multiple words in grep
[Computer]$ grep "foo|bar" filename
I understand the above command should return each line in filename where there exits "foo" or "bar". The man pages confirms | as the Regex or symbol and the code ...
13
votes
2
answers
9k
views
Removing files matching a numeric range regular expression
I have a folder which has many files. Some of the data files are labelled 1, 2, 3, ..., 300
I want to remove these data files using the terminal. How do I do this?
I want to do something like
rm ...
10
votes
3
answers
29k
views
Windows: File copy/move with filename regular expressions?
i basically want to run:
C:\>xcopy [0-9]{13}\.(gif|jpg|png) s:\TargetFolder /s
i know xcopy doesn't support regular-expression filename searches.
i can't find out how to find out if PowerShell ...
9
votes
2
answers
42k
views
Remove text after @ sign
I am trying to use notepad++ and regular expressions to edit a document.
I have text in this format
123.45607894.165@abcd;aba
23.456@av1;084
9871.001@fab:9782581afa
And I need to get only the first ...
8
votes
2
answers
11k
views
Is there any pdf reader that supports word searching with regular expression? [closed]
Possible Duplicate:
Is there software to allow me to search a PDF file with Regex?
I sometimes would like to search some particular words in a PDF file, however there are always a lot of unwanted ...
7
votes
3
answers
32k
views
How to make regex match across multiple lines in Notepad++?
I have a javascript file with millions of lines. The problem is that IE doesn't support , (comma) followed by } (curly close bracket).
In Notepad++ I'm able to find all the commas which are being ...
6
votes
2
answers
37k
views
Merge Excel rows from two sheets
I'd like to start this question by apologizing, there are numerous questions about merging excel rows, still, after browsing the web AND the list of "Questions that may already have your answer", I ...
5
votes
2
answers
6k
views
How to delete all files that don't have a certain string in their name
I have seen Deleting all files that do not match a certain pattern - Windows command line
However, I have not seen anything regarding how to delete everything that does not contain a certain string ...
5
votes
1
answer
7k
views
remove numbers from filenames in Mac OS X
I have a directory full of files with names in this format (with numbers as the start of each filename):
102_file.txt
104_list.txt
242_another_file.txt
I would like to rename them as follows (i.e. ...
3
votes
4
answers
40k
views
How to extract IP address from the log's string with regular expression and Notepad++
I've such kind of strings from the log file
rule family="ipv4" source address="54.246.81.158" reject
rule family="ipv4" source address="175.36.129.24" reject
How can I match an IP address from every ...
3
votes
4
answers
10k
views
Regular Expression for Find and Replace in Microsoft Word
I want to remove leading and trailing tags from country names.
In my example those tags are <li> and <a>.
<li><a href="http://afghanistan.makaan.com/">Afghanistan</a><...
3
votes
1
answer
2k
views
VIM: Yank multiple non-continous chunks of text into a registers
I have some lines of text that follow a pattern and some that don't. I'd like to copy the lines that follow this pattern and then copy/yank them into a register so that I can paste them as is ...
2
votes
2
answers
1k
views
Matching a sentence with grep
I'm trying to grep for the full sentence containing a search term. I've tried
grep (^.|\.\s).*searchterm.*(\.\s|\n)
but it's not working and I'm not sure why.
To clarify: I want stdout to print the ...
2
votes
6
answers
3k
views
How can I replace end line with fixed text when the next line begins with a defined set of characters?
I have several big files with some measurements.
It looks this way:
N 12344;PE 9.9999999;...
#S 0 0 31 44 75 130 165 196...
#S_+ "2 5 2 3 3 1 1 2 3 1 2 2...
N 12345;PE 9.9999999;...
#S 0 0 34 57 ...
1
vote
3
answers
2k
views
Regex: Remove every two or more spaces between specific tags and leave just a space instead
I want to remove every two or more spaces between specific tags and leave just a space instead:
For example:
<p class="text_obisnuit"> The context of articles, stories, and conversations ...
1
vote
1
answer
978
views
LibreOffice Writer: copy from a "Find all" search and paste to a list
I am currently working on a PhD thesis in law, which naturally uses a lot of abbreviations. As is customary, I want to include a list of abbreviations and their corresponding terms.
All my ...
0
votes
1
answer
143
views
Notepad++ Deleting everything apart from 40 variables, putting them on their own line, combining regex
I am in Notepad++. I have the following data embedded in a large html file. I want to get the variables before the </ix:nonNumeric> at the end of the lines, onto their own lines by themselves so ...
221
votes
5
answers
220k
views
How to ignore certain filenames using "find"?
One of my favorite BASH commands is:
find . -name '*.*' -exec grep 'SearchString' {} /dev/null \;
which searches the contents of all of the files at and below the current directory for the specified ...
90
votes
6
answers
181k
views
Delete files with regular expression
I Tried to delete files that starts with A and ends with 2 numbers but It doesn't do a thing.
What I tried:
rm ^A*[0..9]2$
Where am I wrong?
58
votes
6
answers
46k
views
How to run a regex search on Google Chrome or Firefox?
How can I search for expressions like 'foo|bar' on webpages using browsers like Google Chrome or Firefox?
53
votes
6
answers
77k
views
Is there a linux command like mv but with regex?
For example I want to mv (.*?).sql $1.php,
is there a command that lets me specify renaming patterns?
47
votes
5
answers
76k
views
Export all regular expression matches in Textpad or Notepad++ as a list
In Textpad or Notepad++ is there an option to export all the matches for a regular expression find, as a single list?
In a big text file, I am searching for tags (words enclosed in % %), using ...
44
votes
11
answers
32k
views
How can I delete everything after the first column in Notepad++?
I'm trying to get rid of everything after a column in Notepad++. Column mode is not an option. Is it possible?
What I have:
70.97.110.40 159 ms [n/a] 21
...
27
votes
8
answers
38k
views
Use Notepad++ to change under_score_case to CamelCase?
I can write a regular expression in NP++ to find under_score_case.
I can use TextFX in NP++ to change case to upper and lower case by highlighting and selecting.
How can I use either NP++'s Find/...
25
votes
5
answers
425k
views
Using wildcard search/replace in Notepad++
Here's my problem: In a .txt file, I need to find and replace thousands of instances of syntax like this:
(see (a053007djfgspwdf))
or
(see (a053007djfgspwdf) and (a54134xsedgeg))
or
(see (...
24
votes
5
answers
22k
views
Grep tool for XML [closed]
I am looking for a good tool to perform grep-like operations on XML - for example, extract certain attributes only.
Grep itself can't handle it - any DFA-equivalent tool can handle only non recursive ...
20
votes
1
answer
8k
views
How do I include newlines in a search in less?
How can I search for newlines (or end of lines) as part of a search using less?
For example, I'd like to search for length=9\n, but don't want to merely search for length=9 because that'd get matches ...
20
votes
3
answers
66k
views
How to delete files on the command line with regular expressions?
Lets say I have 20 files named FOOXX, where XX is the number of the file, eg 01, 02 etc.
At the moment, if I want to delete all files lower than the number 10, this is easy and I just use a wildcard, ...
16
votes
6
answers
54k
views
rsync using regex to include only some files
I am trying to run rsync to copy some files recursively down a path based on their file name pattern, case insensitive. This is what I have done to run rsync:
$ rsync -avvz --include ='*/' --include='...
16
votes
1
answer
1k
views
Why there are so many regular expression variants? [closed]
Today when I reviewed our project's source code, I found there are lots of unnecessary "spaces" and "tabs" located at each line's end. So I decided to delete them with regular expression.
However,...
16
votes
2
answers
51k
views
Notepad++ find and replace within a constant string
Using notepad++ I have the following text.
This little piggy went to market, \textbf{smith1774}
This little \textbf{ben1864} piggy stayed \textbf{mueller2867} home,
This little piggy had roast beef
...
14
votes
4
answers
5k
views
How to install regexp enabled 'rename' on fedora?
I have a batch rename task and I find the 'rename' command in Ubuntu and Fedora is different.
In Ubuntu, rename is written in Perl and has regexp support. Is there anyway to install it on Fedora?
10
votes
1
answer
2k
views
Replacing [0-9] with [A-J] not working with sed
I am working on a command that replaces all digits 0-9 with their corresponding letters in sed. I know I'm doing something wrong, but sed is not interpreting the replacement regex as anything but a ...