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 ...
2
votes
1answer
20 views
Linux “find -regex” doesn't handle binding
I have the following files, and need to match them like:
./foo.bar1.sh -match
./qux/foo.bar2.sh -match
./foo.sh -match
./baz.sh -no match
./foo.bar3 -no ...
0
votes
0answers
17 views
Pattern matching gnmap fields with SED
I am testing the regex needed for creating field extraction with Splunk for nmap and think I might be close...
Example full line:
Host: 10.0.0.1 (host) Ports: 21/open|filtered/tcp//ftp///, ...
2
votes
3answers
64 views
How to substitute multiple lines between delimiters
Given the text example:
.... text ,..
{{{python
string1 = 'abcde'
string2 = '12345'
print(string1[[1:3]])
print(string2[[:-1]])
}}}
.... text ,..
The [[ and ]] also appear outside of {{{ too. ...
1
vote
1answer
33 views
Find/replace underscored words to camelCase words using regex?
I have a ton of text files that are tagged with underscore-connected words like @some_text, but I would like to convert those to tags in camel case, like @someText. How can I use regex (either in vim ...
0
votes
1answer
23 views
Converting between a vim replace and a perl pie replace
So I have a file test.txt, that contains,
home -> range
If I edit the file in vim and run the command %s/^\(.*\)->\(.*\)$/\2 ::= \1 ;/g it converts the file to
range ::= home ;
which is ...
0
votes
0answers
46 views
Linux replace ^M$ with $ in csv
I'm working on migrating from MDaemon to Google Apps. As part of this process I'm exporting the contacts and calendars for all of our users into CSV files then reading them into a perl script and ...
3
votes
1answer
44 views
What would be the regex to use to find a potential space at the very end of files with Notepad++?
I have hundreds of files to look in to check if there is not an extra line with a space which cause my PHP application to throw hundreds of Warning in the logs.
I cannot find the regex to match a ...
0
votes
0answers
12 views
Textpad regex cursor placement after the replaced text
I have the following regex to find a date and replace it with some text plus the tags but the subsequent replaces are finding the replaced text instead of the next date
Regex: ...
0
votes
1answer
25 views
Using RegEX To Prefix And Append In Notepad++
I found this question on StackOverFlow: http://stackoverflow.com/questions/283608/using-regex-to-prefix-and-append-in-notepad
It worked great but i also need to include lines that have non-alphabet ...
0
votes
1answer
23 views
Difference between 'apropos *' and 'apropos .'
OpenSUSE 12.01, KDE, kernel 3.1.9-1.4-default
Trying to get all man pages. Basically the answer is 'apropos .' or 'man -k .'. What I was wondering about is why does 'apropos *' only returns about 300 ...
5
votes
2answers
84 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 ...
1
vote
3answers
72 views
sed: replace each occurence of 4 spaces (at beginning of a line) with 2 spaces
Say I have this (puppet) file with an indentation of 4 spaces (I have a bunch of them that I have to process):
# init.pp
class hardwareid (
$package_name = $hardwareid::params::package_name,
...
0
votes
1answer
31 views
Fail a teamcity build if warnings in log exceed a certain number
I am using the latest version of TeamCity and I'm trying to get a build to fail if the number of occurrences of the word "Warning:" exceed a certain level.
I am using the new build failure conditions ...
1
vote
2answers
31 views
Emacs Regex Capture+Replace: (abc (:key map)) -> (abc (-> map :key str))
I have a bunch of (clojure) code that looks like this:
(content (:some-key some-map))
I want this code to become:
(content (-> some-map :some-key str))
I tried:
(content (\(:[-a-z].*\) ...
1
vote
1answer
39 views
Replace a block of numbers in sed
I've been fiddling with this for a while now and can't seem to figure it out.
What I'm trying to do is replace all numbers in a file with a single #.
Sounds simple, and it should be, but I can't get ...
10
votes
3answers
282 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 ...
1
vote
2answers
81 views
Perl for matching with regex in Terminal?
I'm trying to familiarize myself a little with perl to use for regex searches in Terminal (Mac). Now, I'm not really looking to learn Perl rigourously, just trying to find out how to do some simple ...
1
vote
1answer
33 views
Is there any pdf reader that supports word searching with regular expression?
I sometimes would like to search some particular words in a pdf file,however there are always a lot of unwanted words for me.For instance, when I would like to find "scala" in a pdf paper,I always ...
0
votes
2answers
58 views
grep doesn't produce the correct output when run on find command
My task was to print the number of files in the current directory without using ls and wc commands.
I had typed the following lines in the script:
#!/bin/bash
find . -maxdepth 1 -type f \( ! -iname ...
3
votes
2answers
65 views
Append lines one after another in notepad++
How do we achieve the following using replace function in notepad++?
Transforming the following
cow
horse
elephant
camel
into
'cow','horse','elephant','camel'
I know ^ and $ (under Regular ...
1
vote
2answers
76 views
How to use command “find” to list files with specific filename length?
In my folder I got files like
/data/filename.log
/data/filename.log.1
/data/filename.log.2
/data/filenamefilenamefilename.log
/data/filenamefilenamefilename.log.2
I wish to use "find" command to ...
0
votes
1answer
21 views
Replace Certain Elements in a Path with a Tag
I want to modify paths with a certain pattern.
For example
./foo/1023023/43655345/bar/
becomes
./foo/_dir_/_dir_/bar/
The pattern is always preceded by /foo/ followed by 2 directories that have ...
2
votes
1answer
100 views
Regex in Notepad++ 6
So, Notepad++ got updated to v6.0. One of their new features is PCRE (Perl Compatible Regular Expressions).
I tried to use this new feature to find and replace things in a file. I tried the regular ...
0
votes
3answers
81 views
Parse and remove parts of strings between delimiters
I would like to go through a file and remove certain sequences in between delimiters.
For example
drw---- 00000000 11111111 0 ./a/
drw---- 00000000 11111111 0 ./b/
d------ 00000000 ...
0
votes
2answers
80 views
Notepad++ Find & Replace (with regex) issue
I'm going crazy on a weird issue, I've been trying to find this text:
CREATE Proc [dbo].[procName] (@EMI_ID numeric(8), @ESYNTH_ID numeric(8), @FLD_ID numeric(8), @SYNTH_ID numeric(8)) As
And I use ...
0
votes
2answers
107 views
“sed” regex help: Replacing characters
I want to change characters in a XML file by using sed. The input looks like this:
<!-- Input -->
<root>
<tree foo="abcd" bar="abccdcd" />
<dontTouch foo="asd" bar="abc" ...
1
vote
1answer
23 views
Looking for a command that will return the proc, func, etc that uses another proc, func, etc
Grep-ing for a function name to see where it's being used returns a list of rows and row numbers. Is there a smart way of using grep and awk to get the name of the calling procedure instead?
Thanks
0
votes
1answer
181 views
Does anyone know a Chrome extension for search/replace using regular expressions? [closed]
I want a Chrome extension that can do text replacements using regular expressions. Does anyone know one?
0
votes
1answer
123 views
Extract substring before = sign using awk
Say I have some file with a bunch of lines in the form
someString=someMoreCharacters
anotherString.blah=foo=bar
blah.blah.blah=foo.bar.=foobar
Desired output
someString
anotherString.blah
...
2
votes
0answers
47 views
Is there a way to do rich text formatting with regexes?
I'm trying to edit a large public domain text for publication. One of the things I have to do is make each paragraph's heading bold. Since the heading always begins with an open-paren and ends with a ...
2
votes
1answer
349 views
Notepad++ Wildcard
In Notepad++, how would I go about removing the content in brackets (brackets included).
4, Bone Powder, (Ryu) 2000
7, Bone Powder, (DC_Terminator) 5555
7, Bone Powder, (The_Lion_Elder) 5000
5, ...
3
votes
2answers
92 views
Howto search in PDFs using regular expressions?
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 ...
1
vote
2answers
47 views
Vim pattern for replacing ftp links with local
Question
I'm going to be sorting through a large mass of html files and replacing links to an ftp site with local links. I am using vim and I am trying to figure out a pattern to use with ...
0
votes
1answer
61 views
Extract URLS from code statements in JS files
All,
I want to extract all URLS mentioned in code statements in all js files in a folder.
For e.g. if a js file contains this piece of code:
var myURL="http://yahoo.com/signup"
//var ...
0
votes
0answers
43 views
Creating a preview folder from many image subfolders
I am trying to create a preview gallery from a large group of gallery folders on Linux Mint KDE. They are arranged like this:
MainFolder/Title/Subtitle/image1.jpeg OR
...
2
votes
3answers
60 views
Get LVM size using AWK?
I'm in need to find out the LVM size of image vm001. Let's say I have a LVM volume called /dev/VGgroup/vm001. Now using lvdisplay I can find out the size:
--- Logical volume ---
LV Name ...
1
vote
3answers
191 views
excel vba - multiline regex not working
In cell A1 of an excel sheet I have the following contents inside the cell:
select a.id, b.type, c.name
from blah a,
blah2 b,
blah3 c
where a.id = b.key
and b.key = c.id
;
Either of the below ...
1
vote
0answers
158 views
Regular expression replace in Textpad where search term spans multiple lines
Is it possible to do a regular expression search and replace in Textpad where the search term spans multiple lines.
e.g. document contains:
Hello
ab_c
D_EF
12_3
World
I would like to replace ...
0
votes
0answers
47 views
RegEx For Finding DOB In A String Of Six Contiguous Numbers (mmddyy)
I'm trying to find a regex string that will recognize a DOB in the format of mmddyy. As far as I know though, regex doesn't know where individual number sets begin/end if they're right next to one ...
1
vote
3answers
137 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 ...
1
vote
1answer
86 views
Using MS Word as a code editor
As this is an editor question.. this has high risk of becoming a flame war. Please, if you're compelled say "real programmers use Vim" or Emacs or whatever, turn away now.
60% of the time I "write" ...
1
vote
0answers
106 views
LogRotate use regex for filename
I have a custom logging class that creates a log for each instance of the process and adds a unique id to the log file name, example:
process.1234.log
process.1235.log
Also I can add a date/time ...
0
votes
1answer
68 views
Why isn't this egrep invocation case sensitive?
I'm using the following egrep invocation as a filter for an ant build:
egrep '\[.*\]|BUILD|time\:'
The build.xml file has a huge number of empty or unimportant targets that I'm trying to filter ...
0
votes
3answers
132 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?
0
votes
1answer
56 views
vi substitution matching
I am able to pattern match a regex in vi, but when I add the replacement string, vi thinks that is part of the regex match. This occurs despite use of various different delimiters. Is there some way ...
0
votes
1answer
89 views
How to insert thousand separator with `sed`?
I want to insert thousand separator into a number sequence with sed and this ugly RE sed -e :a -e 's/\(.*[0-9]\)\(\([0-9]\{3\}\)\(,[0-9]\{3\}\)*\(\.[0-9]*\)\)/\1,\2/;ta' [filename].
Is there a more ...
3
votes
2answers
107 views
How can I find/replace instances of double hyphens (--) with triple hypens (---) in vim?
I know there's probably a way to do that using regex, but I can't quite seem to figure out regex in vim. I tried searching: /-\{2} but it catches triple hyphens, too.
I also can't just do a ...
0
votes
2answers
74 views
VI make every first letter that comes after a underscore uppercase
Found this site:
http://unix.t-a-y-l-o-r.com/VMswitch.html
And it works for the first character but my lines are line this
this_is_a_string
And I would like this
This_Is_A_String
Any ...
0
votes
2answers
177 views
Notepad++ RegEx does not work with min and max occurence
I want to find two or more (max 9) white-space characters and replace it with newlines.
My RegEx syntax is as follows:
[\s]{2,9}
However, Notepad++'s RegEx doesn't seem to work with curly braces. ...
2
votes
2answers
98 views
What is a simple regular expression to rename multiple files?
Suppose that, on a UNIX system, I have a directory that contains the files abc.css, abc.js, and abc.html. In the console, is there a command that I can run that will rename the files to xyz.css, ...