Regex (or regexp) is known as regular expression matching of patterns, strings or characters in, for example, a large text file. Questions should be tagged as such whatever the programming language involved and the tag can also apply to command-line or graphical programs that have regex plugins or ...

learn more… | top users | synonyms

1
vote
0answers
14 views

Vi syntax highlighting for words followed by a parenthesis

I want to change the color of a keyword that is followed by a left parenthesis in a .R file. For instance, when I type length(), I want the word length to be highlighted (and not the parentheses), ...
0
votes
0answers
16 views

Fail2Ban Regex SSH Will not Match Auth.Log - Searched Everywhere for a Solution

Im trying to get Fail2Ban to work with the SSHD Config provided. When i run fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf The Output is as follows ...
0
votes
1answer
16 views

Explain in details egrep line

Hi i found in the internet egrep line. The line founds the longest line in the text. But i dont understand specific elements. Maybe someone could explain me all line? Here it is: egrep -n "^.{$(wc -L ...
2
votes
2answers
72 views

Change text in many files

I have a C++ project, where each file has at its beginning some lines of license. Now, that my license have changed, I need to update it in each file. I don't want to do it manually, since its lots of ...
1
vote
2answers
94 views

How do I use regex to remove all punctuation and symbols?

I'm using Python 2.7 regex. I need to remove all symbols, punctuation, numbers and whitespace from strings in different languages. For example, these two strings: the following characters: ...
-1
votes
0answers
18 views

how to find broken html tags with regex?

I need to find/filter some broken html tags from some text. They look like this where the leading "<tag" are missing and they can have a variety of attributes. Fortunately, all broken strings seem ...
0
votes
1answer
36 views

How can I uninstall only one of the versions of Libre Office?

I have both versions of Libre Office installed - 4.3 and the default: dpkg --get-selections | grep -v deinstall | grep libreoffice shows libreoffice-avmedia-backend-gstreamer libreoffice-base-core ...
5
votes
1answer
128 views

How to rename the set of files with pattern

I have files which has name as following: P50_FR_8_q2_scrolls.csv Here the value 50 and 8 needs renaming & The results should be something like: P21_FR_3_q2_scrolls.csv I tired few ...
1
vote
1answer
87 views

Undo apt-get remove --purge

I wanted a fresh install of Python and ran sudo apt-get remove --purge python. Apparently it has killed almost everything I had installed in my system. Looking at the history.log I guess I could ...
1
vote
1answer
38 views

Ubuntu rename command regex not working

I'm trying to use the rename command to rename a bunch of images in a folder. I have this list of images, image.php?x=10 image.php?x=25 image.php?x=50 image.php?x=75 I'm trying to rename them to ...
0
votes
3answers
35 views

Batch Rename Using Regex but Mainaining Some Substring

I made a lot of research before I put this question. I found a different links to do batch rename using regex like this and other similars: *Pattern based, batch file rename in terminal My problem ...
3
votes
1answer
112 views

What happens if we add a dot at the end of sudo `apt-get autoremove`

sudo apt-get autoremove . OUTPUT: WARNING: The following essential packages will be removed. This should NOT be done unless you know exactly what you are doing! apt libapt-pkg4.12 (due to apt) libc6 ...
4
votes
5answers
194 views

Bash script programming: how to match pattern in string?

How I can get this whole value 7I45432ZX from below lines: PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 This is the code I tried: grep ...
2
votes
2answers
115 views

Regular expression that matches all multiple seperate expressions

It's admission time in India and I am trying my best to get the best college I can for engg. I have got a pdf file which contains a table which looks like It contains about 2500+ entries and I ...
0
votes
2answers
54 views

Regular expression

I have a code that is looking for a specific pattern in my log files. Usually it begins with Association ID = (This is what I am looking for in parenthesis). Now the code I have made so far is ...
1
vote
4answers
93 views

Change directory structure from /YEAR/MONTH/DAY/ to /YEAR-MONTH-DAY

I need to change my directory structure for my photos from /YEAR/MONTH/DAY/ to /YEAR-MONTH-DAY I know this can sort of be done with exiftool, but it will only work on files containing EXIF-tags, and ...
1
vote
2answers
42 views

how can i find all files that contain embedded crc32's

how can I find all files that contain embedded crc32's e.g. Mydocument190_[F285E17D].pdf using the find command to clarify the crc32's are always within brackets [F285E17D] and the file names may ...
0
votes
0answers
168 views

How can I use C++11's <regex> on Ubuntu?

I normally use the G++ compiler, but I don't have anything against using clang++. Reading about this, I get the idea that G++'s implementation of C++11's regex might not compile, and if it does, it ...
1
vote
2answers
133 views

Extract full link of a div element

I'm downloading episodes from a series, but I'm tired for joining in the site, copying the link and downloading it for each episode. First, I join in the site and I get the HTML code. The code is ...
1
vote
3answers
92 views

Forming IPAddresses from Text file

I have a huge text file that contains IP addresses scrambled all over but not in one unit for example. So what the@192@ heck are you doing@168@ in my house @10@.you were not @16@ supposed to be ...
4
votes
2answers
775 views

regex search works with `grep -E` but not with bash script?

I use the same regex with grep and it gives me a match but when doing it in a bash script, it return no match. Test String(part of the file testregex.txt): <a ...
1
vote
1answer
67 views

How to get sub-string for a string using pattern analysis?

I want to get sub-string of any string using pattern analysis. Example String: <string module name="Jai" fathername="S.S. Khan" phone="1234"> <address complete="startz us" /> ...
4
votes
2answers
168 views

Using Regex Breaking a text on the last digit using linux tools like sed, or awk

I have the following list that I want to break on the digit. For example: From: 103Ru 103mRh 104 1041 To: 103 Ru 103 mRh 104 1041 I would like to use Regx with sed or maybe awk in order to ...
2
votes
5answers
264 views

Help to build this expression using sed

I have a text file and I need to get rid off the entire information just before the = symbol in each line, for example: The line: File 1515 = foo.txt needs to look like this: =foo.txt So, I had ...
2
votes
3answers
24 views

Searching through output of more command

When searching through the output of more command how can I search for a phrase that includes spaces in between? When I search for a phrase like "typedef struct audiodev" it doesn't find the phrase in ...
1
vote
1answer
36 views

Regular expression problem, not finding the results I'm expecting

I am writing a script to install some things and I'm having trouble with a regular expression I am using. I have the Wine repository in my apt sources (ppa:ubuntu-wine/ppa) and I am using the ...
2
votes
1answer
74 views

Capture groups are ignored when renaming files

I have a number of files in this format: ##.## - File name.mp4 I want to rename them to: s##e##.mp4 This is what I came up with: rename -n "s/^(\d{2})\.(\d{2}).*/s$1e$2.mp4/" It works when I ...
4
votes
1answer
2k views

Using Modifiers of Perl-compatible Regex (PCRE) in grep

According to grep --help and man grep, we can use the -P option in order to interpret the pattern as a Perl regular expression (PCRE, to be precise), instead of the default POSIX basic regular ...
0
votes
3answers
59 views

How to recursive regexp rename double dashes

I am using Wordpress Eazyest gallery to create 2000 galleries. Some files have double or triple dashes in filenames. For instance: abc---def.jpg These files are uploaded via FTP. On Wordpress admin ...
0
votes
1answer
611 views

How to replace strings in file without regex?

I need to replace some strings in files (from command line) but I don't want to use sed -i because my string contains lots of funny characters which need to be correctly escaped. Is there a way to ...
0
votes
1answer
239 views

how can i use grep to find IPV4 Number in a pcap file with regx syntac?

I'm new in ubuntu. I have this IP regex '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' I have a network pcap file, I want to use this regex and the grep -e to find all IP address in the ...
3
votes
1answer
95 views

Did grep change how it uses regexp?

I used to run commands like: find /dev | grep sd* to output a list of all the drives attached to my computer. It appears that I now have to add any random character before the star in order to get the ...
0
votes
1answer
39 views

Formatting a file to use it with fortune in the terminal

I have a big text file with 'Terms' and its 'Definition' separated by spaces(variable). I want to use it in fortune cookie format. Current file format: **term1** this is my definition with ...
0
votes
1answer
232 views

Passing Int variable to re.findall

I'm trying pass year variable to re.findall, but it doesn't work(no errors). Can anyone specify where I'm going wrong? year=2013 links = re.findall(r"('+year+'-.*\/t.*.html)", line)
0
votes
2answers
188 views

Extracting specific data in a file using regex [closed]

Following info i want to extract from a file which has different version,release date,CVE number. Can anyone show me how to retrieve that information using regex..? Sorry if this is a terrible ...
1
vote
1answer
231 views

Extracting URL links from a File

Following code is to extract /support/security/bulletins/*.html links from a file(urlfile contain about 1000 links) to urlsort file using regex,But i'm weak in regex can anyone show me how to do ...
2
votes
2answers
95 views

Removing a string of files with rename

I have been trying to batch rename a bunch of files so that they are consistent and fit within the name structure that I have come up with. For instance,I am renaming comics, and so I have a directory ...
1
vote
1answer
559 views

Grep Regex match not returning result as expected

I have several Ubuntu servers and there is some behavior that has me curious. On any newly installed machine (Ubuntu Server 12.04.3 LTS), if I run: echo "testbla123" | grep -P -o [0-9]* This will ...
1
vote
1answer
195 views

Use Postfix to dump mails to local folder using regex

How do I use postfix to filter certain emails (by domain or sender) and for those who fall under the rule (filter) save locally and those who doesn't to relay regularly ?
3
votes
1answer
39 views

REGEX behaves differently!

When running the following echo "abc>asf<tfg"|sed 's/.*>\(.*\)</\1/' The output is: asftfg I don't understand why tfg gets printed? My expected result is asf. Though, it works ...
1
vote
0answers
141 views

Grep word in one file, and use that word to match in another file, adding the thing that follows the match [closed]

I want to grep several words in file1, and use each word to grep what follows after its match in file2. And then I want to add the thing that followed the match to the word I used into file03, so that ...
-1
votes
1answer
162 views

Complicated batch rename file problem

I did find the program pyRenamer, but I don't seem to understand it. I have hundreds of files with name like main.php?g2_view=core.DownloadItem&g2_itemId=6027&g2_serialNumber=3 here ...
2
votes
1answer
169 views

How to monitor a local file for changes, apply a RegEx replace on it and save/overwrite to a destination file?

I'd like to start a script or something that watches a text file for changes. When the file changes I want to run it through a RegEx parser to replace some text and then output the modified file to a ...
1
vote
1answer
151 views

how to parse watch command output to last 5 digits?

From the command watch -n1 "ifconfig eth0 | grep GiB". I have output given below, Now i just want the last 5 digits before (GiB). I wrote an regex for it, and it seems to work ...
7
votes
2answers
4k views

Pattern based, batch file rename in terminal

I need to rename the following: file_001_loremipsum.png file_002_dolor.png file_003_sit.png file_004_amet.png file_105_randomness.png into upl_loremipsum.png upl_dolor.png upl_sit.png upl_amet.png ...
0
votes
2answers
1k views

Inserting variable into sed command in bash script

I have text file similar to this: Some-text Keyword Some-text Some-text Keyword Some-text Keyword Keyword I want to replace every "Keyword" with "number.extension" where number is 1 at first ...
2
votes
1answer
167 views

Delete lines starting with pattern from a file

I tried several commands: tr, sed but to no avail. Here's the file: > ... > ... > setEPS() > postscript('images/boxplot_default.eps') > ... > ... I want to delete those two ...
1
vote
2answers
65 views

Unexpected anwer from the following regex?

I have this following file:- $ cat numbers a1 12 12345 123456 19816282 1@$%6 I am using grep "^[0-9]\{1,6\}$" numbers which is giving me the following results:- 12 12345 I was expecting 1@$%6 ...
2
votes
1answer
582 views

How do you use sed to edit a CSV file?

I have a CSV file like this: hostname1 | role1 | environment | tag,list | | hostname2 | role2 | environment | tag,list,longer | | hostname3 | role3 | environment | | | I need a sed expression that ...
3
votes
2answers
923 views

How can I parse a YouTube URL?

How do i extract only http://www.youtube.com/watch?v=qdRaf3-OEh4 from a URL like http://www.youtube.com/watch?v=qdRaf3-OEh4&playnext=1&list=PL4367CEDBC117AEC6&feature=results_main I ...