A regex, also known as a regular expression or regexp, is a description of a set of strings with certain properties. For example, \d{5} matches a series of 5 digits, such as 43822. Use this tag when on the hunt for scripting syntax (in perl, python, sed, grep, awk, etc.) which will match a given ...
1
vote
1answer
42 views
Notepad++ regex Replace, using match variables
In Notepad++, I want to perform a find-and-replace, providing a variable in the 'Replace with' field, which references a match from the 'Find what' field. Any ideas?
I tried supplying (find) foo (\w) ...
0
votes
2answers
50 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 ...
1
vote
1answer
21 views
regex search on google-chrome or firefox browsers?
How can I search for expressions like 'foo|bar' on webpages using browsers like google-chrome or firefox?
0
votes
0answers
36 views
regex pattern for various number groups
I am parsing a list of code numbers, they have a pattern of 12345.1211. They are space delimited.
They sometimes will have a space followed by one - three addition number patterns like:
1221.121 11 ...
1
vote
0answers
41 views
Expressing complicated regular expressions concisely
Is there some way to write this simple regular expression more concisely? (here I am using separate lines to improve readability, even though I normally wouldn't use them)
(
(regex ...
0
votes
1answer
41 views
Regex editor application for Mac
I'm working with regular expressions on Mac and I'm using:
http://reggyapp.com/
But it does not show the exact matches numbered. I'm looking for other applications. Something similar to regex ...
2
votes
2answers
63 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 ...
2
votes
1answer
21 views
Is there a way to let Emacs' regexp based commands such `query-replace-regexp` use Perl regexp?
Is there a way to let Emacs' regexp based commands such query-replace-regexp use Perl regexp?
I am hoping there is some reasonably simple way to achieve this, for example, by adding code in .emacs.
0
votes
1answer
67 views
How to search emails by matching header fields against regex “in” Thunderbird?
How to search emails by header fields such as Subject, Sender, Receipt, against regex? The emails are fetched and read with Thunderbird. But the searching doesn't need to occur through Thunderbird ...
0
votes
1answer
48 views
Sed pattern for multiple lines
I want to remove all create table statements from a mysql script, but the statement runs over multiple lines.
Like this: Create table ......NEWLINE... NEWLINE... NEWLINE....;
So I tried this ...
0
votes
1answer
17 views
seq with regex, error message for mysql quotes
Is there some tool that auto quotes regex for seq?
I can't figure out what I'm doing wrong. I always get this error unterminateds' command`
sed -i 's/INSERT INTO `tablename.*`/INSERT INTO ...
0
votes
1answer
36 views
sed + does not work on solaris
I try to use a sed line with a + on a Solaris machine and on a Linux machine.
on Solaris sed does not remove the strings until the first number like I want:
solaris:/ ROOT > echo ...
0
votes
1answer
27 views
Optimize regex formula for checking filenames
I'm working on a regex formula that will check if the supplied file for processing has either of the following formats:
SN1234_filename.pdf
SN1234_filename.pdf.zip
This is what I have right now: ...
0
votes
1answer
58 views
Is changing case with regular expression supported in editors other than Vim?
Today I had the need to change all url encoded strings like %BF to lower case ones like %bf. My first reaction is to write some Ruby scripts to do this conversion, and I began to consider use the gsub ...
0
votes
0answers
12 views
sed grouping cancels out results?
When running the following sed command under Windows (to uppercase a keyword which isn't part of another word):
"c:\Program Files (x86)\GnuWin32\bin\sed.exe" -e "s/[^a-z]*declare[^a-z]*/DECLARE/I" ...
0
votes
2answers
91 views
Validate IP addresses in user input with batch script
Related:
Script to assign and remove arbitrary secondary IPs to an interface
I'm trying to augment the script in the above question, by validating the user input so that the script will only ...
1
vote
1answer
26 views
Tool to manipulate text in web form fields?
I'm looking for a way to manipulate text in form fields. For example, if I have a large textarea "body" field, from my browser I want to be able to highlight a piece of text in that textarea, for ...
2
votes
1answer
23 views
Replace files with others from other folder matched by first token in filename
Lets say I have two folders:
ls /A/
01 - IncorrectName.flac
02 - otherincorrect.flac
ls /B/
01 - CorectName.flac
02 - Othercorrect.flac
How would I move the files from dir A to B, ...
0
votes
2answers
93 views
How to extract a version number using sed?
I'm trying to find the best regular expression to extract a version number from a string. For example:
echo "Version 1.2.4.1 (release mode)" | sed -ne ...
1
vote
2answers
124 views
Replace umlauts with regular expressions
I would like to sync several folders on my local Mac with a remote server via SFTP. As the existing umlauts appear to be problematic for my syncing software (Deltawalker), I am looking for a way ro ...
1
vote
1answer
39 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
...
0
votes
2answers
60 views
List directories containing files that match a regular expression
I would like to set up a simple filtering system on my FreeBSD server that allows me to create arbitrary "views" of directories.
For instance, I'd like to be able to list all directories that match ...
2
votes
2answers
118 views
Textmate: regular expression to replace matches preserving case?
How can I use a single search / replace to replace all words town with village preserving the case of the first letter in this sentence:
Towns are small cities. I live in a town.
0
votes
1answer
50 views
Regex to match starting node of XML without the tag name [closed]
share [fb] share [tw]
I have XML like
<A>
<B>
<C>
Hello World
</C>
</B>
</A>
I want to replace the starting tag's "<" with "<ns:" in each tag ...
2
votes
3answers
85 views
Remove all files containing a pattern
Suppose I have a directory with files and subdirectories underneath it. Some of the files contain a pattern "^File:" in their contents.
Is there some way I can use grep and a bash command to remove ...
1
vote
1answer
89 views
Linux find and grep for files not match pattern
I'm trying to search the entire file system for specific text. This command does that but it gets hung up in certain directories like '/proc':
find / -print0|xargs -0 grep whatever
What I'd like ...
0
votes
1answer
40 views
How do I create a shortcut for a find and replace command in vim?
I have a vim (well, sed really) find and replace pattern I use for resetting the AUTO_INCREMENT property in mySQL CREATE TABLE statements:
:%s/AUTO_INCREMENT=[0-9]*/AUTO_INCREMENT=1/g
I use this ...
1
vote
2answers
55 views
Simple REGEX - How to get all lines beginning with “|” - [Pipeline] to the line above ending with [Pipeline]
Explanation
With the help of REGEX I am trying to convert italian synonym database to the following format:
synonym1|synonym2|synonym3
anothersynonym1|anothersynonym2
...........
......
At this ...
1
vote
1answer
54 views
regex to put an actual newline at every \n
I'm writing a bash script that will deal with blob data that needs to be written to a file. The data inserted into the blob is separated by newlines. The command line mysql -e select blobfield from ...
0
votes
1answer
39 views
Searching for *.graphml files with the find utility
I am trying to find all my GRAPHML files under the current directory in bash. So I ran the following command:
find . -name *.graphml
And I get the error message:
find: paths must precede ...
1
vote
2answers
36 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?
0
votes
1answer
243 views
Why doesn't my regular expression work in NotePad++? [closed]
Why doesn't <example regular expression here> work in NotePad++?
4
votes
2answers
66 views
Counting total number of matches with grep instead of just how many lines match
Does grep offer a way to count the total number of matches it makes? The -c option only returns the number of lines that matched the regex, but in this case I have multiple matches per line.
2
votes
4answers
232 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 ...
1
vote
1answer
60 views
Can I use perl based regular expressions on buffers in emacs?
Emacs regex seems to have a few strange rules like escaping brackets. I'd rather use the perl based regex I've always used.
0
votes
2answers
91 views
RegEx find and replace with sed, matching group and replacing on condition
Is this possible with sed?
I'm actually in iTunes using "Track Name Edit with sed" from Doug's Scripts, and I have a collection of tracks that are titled in one of two ways:
Identical string - ...
0
votes
2answers
70 views
File matching pattern on command line?
Can someone help me with a relatively complex command-line file matching pattern?
I've got files in a directory as follows:
1.png
1_thumb.png
1-1.png
1-1_thumb.png
1-2.png
1-2_thumb.png
2.png
...
2
votes
2answers
97 views
How find & replace using wildcards with regex substitution?
Is there a way to use regex substitution with Excel find & replace (in the GUI)?
Using a JavaScript example, I want to do something like this:
"John Smith".replace(/(.*)\s(\.*)/, "$2, $1") // ...
2
votes
1answer
87 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 ...
0
votes
2answers
71 views
Grep log for certain word only if followed by another word
I have a log file with entries like the following:
Input
php notice bob
php notice winner
php notice blah winner
php notice asfsdf test
php erro)r bob ...
1
vote
1answer
33 views
Non-greedy regular expression in ed
Is there a way to do non-greedy regular expression in ed?
I'm aware of the syntaxes for this VIM and perl-compatible regex; that's not what I'm asking about. Sometimes plain vanilla ed is the most ...
0
votes
4answers
76 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 ...
0
votes
2answers
44 views
Regex in excel: Fixing dates, from Apr 1/11 to 1-Apr-11
I have a fairly large spreadsheet and the dates column hasn't been locked down with an input mask/format and users have been using an incorrect dating scheme. Users are inputting dates as Apr 1/11 ...
0
votes
1answer
43 views
OpenOffice.org Writer RegEx
I have some badly formatted text which I am attempting to reformat using the OpenOffice.org Writer's Find/Replace functionality which supports regular expressions as defined here.
The problem is some ...
1
vote
3answers
49 views
SW to replace a string in Windows
I have a text file (actually XML) that I want to be able to change using a command line. In other words, as part of a Windows batch, I want to locate a string (in this case @@@@, which uses a ...
3
votes
2answers
41 views
Unix tool to show files where the content does not match
If I want to see a list of files which contain the word 'FOO' I can use
fgrep -l 'FOO' *
but what if I want to see all of the files which do not contain the word FOO?
I can't use
fgrep -vl 'FOO' ...
1
vote
1answer
50 views
Command that behaves like Emacs' align-regexp
Let's say you have a properties file that looks like this:
prop1 = value1
longerprop = value2
reallylongpropthathasnomeaning = val3
shorterprop = val4
and you want to "beautify" it into this:
...
0
votes
1answer
77 views
Using xcopy /exclude to exclude .o, but include .odt?
From xcopy /?
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
...
2
votes
1answer
146 views
Using regular expressions in Linux with grep
I can't get this simple regular expression to work for matching emails:
'\w*(?:\.\w*)*@\w*(?:\.\w*)*\w\{2,5\}'
It should be working as I have tested it with regex pal
and it works just fine.
I ...
5
votes
1answer
841 views
Find and replace in Notepad++ using wildcards/regex
I have a SQL dump with expressions such as youtubehd:2nj6bykw. The 2nj6bykw can also be a different random string. It is always 8 characters long.
I want to replace youtubehd:2nj6bykw with just ...