I have a list of textfile such as below example:  username1 username2 username3   I want a regex that can make it like following example:  username1:username1 username2:username2 username3:username3   etc..  I've tried many regex with failed attempts.  hopefully somebody can help me..  thank you in advance. regards.
262
I don't really understand regular expressions.  Can you explain them to me in an easy-to-follow manner?  If there are any online tools or books, could you also link to them?
33583
How to extract a text part by regexp in linux shell? Lets say, I have a file where in every line is an IP address, but on a different position. What is the simplest way to extract those IP addresses using common unix command-line tools?
118631
A friend asked me this and I was stumped: Is there a way to craft a regular expression that matches a sequence of the same character? E.g.,  match on 'aaa', 'bbb', but not 'abc'?  m|\w{2,3}|    Wouldn't do the trick as it would match 'abc'.  m|a{2,3}|    Wouldn't do the trick as it wouldn't match 'bbb', 'ccc', etc.
18458
How to make enumerate list format numbers like this:     REG/001 (content)      REG/002 (content)      REG/003 (content)   I already managed to do the following:   \begin{enumerate}[label=\textbf{REG/\arabic*},leftmargin=*] \item content \end{enumerate}   using   \usepackage{enumitem}   but I don't know how to add leading zeros.
91691
I have two files like:  file 1 :  a stringori to replace, this stringori comme again  other stringori2 to replace, stringori2 commes again ...   file 2:  stringori newstring stringori2  newstring2 ...   I want to get the result:  a newstring to replace, this newstring comme again  other newstring2 to replace, newstring2 commes again
24166
It took me a while to word this best.  Problem 1:  Is there a way to find lines in a text file that have the same string at the beginning and the same strings at the end?   Beginning and end strings not necessarily equal to each other.  Text between the two strings is not consistant in number of characters or number of hyphens.  A hyphen is in between notable strings (which I added to my large text file).  For example:  File:    AAAAA-tjhut-ghyut-FILE1.txt   BBB-fhuj-dnbhg-frt76-FILE2.txt   AAAAA-ghtujukr-hgute7gr-xhyutt-FILE1.txt   AAAAA-VGYT-4d7tt-xhyutt-FILE1.txt   CCCC-fjuk-dryy-fhuj-FILE3.txt   Lines to detect:    AAAAA-tjhut-ghyut-FILE1.txt   AAAAA-ghtujukr-hgute7gr-xhyutt-FILE1.txt   AAAAA-VGYT-4d7tt-xhyutt-FILE1.txt   Problem 2:  Is there a way to remove all but one of the lines containing the duplicate strings at the beginning and end from above?  Before:    AAAAA-tjhut-ghyut-FILE1.txt   AAAAA-ghtujukr-hgute7gr-xhyutt-FILE1.txt   AAAAA-VGYT-4d7tt-xhyutt-FILE1.txt   After:    AAAAA-tjhut-ghyut-FILE1.txt   Big thanks for any advice.  Note: I think using the occurances of the first hyphen and last hyphen can be used to locate the duplicate strings.
98888
I have a .txt file with numbers ordered like this (on the same row):  106849_01373    106849_01967    106850_00082    23025.7_01059      I would like to convert them like that:  106849_01373 106849_01967 106850_00082 23025.7_01059   I have no idea which command to use. Can somebody help me with this?
95331
How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#?  Sorry if it's a stupid question, I'm new to Regex.  I know to do it using plan String.Replace, like:  myStr.Replace("\n", "\r\n"); myStr.Replace("\r\r\n", "\r\n");   However, this is inelegant, and would destroy any "\r+\r\n" already in the text (although they are not likely to exist).
40669
I want to reverse a regular expression. I.e. given a regular expression, I want to produce any string that will match that regex.  I know how to do this from a theoretical computer science background using a finite state machine, but I just want to know if someone has already written a library to do this. :)  I'm using Python, so I'd like a Python library.  To reiterate, I only want one string that will match the regex. Things like "." or ".*" would make an infinite amount of strings match the regex, but I don't care about all options.  I'm willing for this library to only work on a certain subset of regex.
84318
Let's say I have a text file like:  john george james stewert   with every name on a separate line.  I want to read the lines of this text file and create a text file for each name, like: john.txt, george.txt etc.  How can I do this in Bash?
26622
Anyone know of a way to reformat either the whole txt file or the selection (I don't really care, either is fine) so that it would would add spaces to align text as columns?  example:  Green 5 Vest Black 6.93 Scarf Red 35.6 Hat   so that it ends up like:  Green 5    Vest Black 6.93 Scarf Red   35.6 Hat   or something similar... I mean the important thing is that they are arranged in an easy-to-read fashion.
48641
I need to split a .txt file into smaller ones containing 100 lines each, including the header. I don't know if this is relevant, but the original file is delimited like this:  COLUMN1 | COLUMN2 | COLUMN3 1 | 2 | 3 4 | 5 | 6 7 | 8 | 9   I need every file generated from this split to have the header line. Also, they need to be generated in/moved to another directory and follow a name pattern, like file_01.txt, file_02.txt, etc
56815
Is there a way to specify a regular expression to match every 2nd occurrence of a pattern in a string?  Examples   searching for a against string abcdabcd should find one occurrence at position 5 searching for ab  against string abcdabcd should find one occurrence at position 5 searching for dab  against string abcdabcd should find no occurrences searching for a against string aaaa should find two occurrences at positions 2 and 4
49149
Given a file, "test.log" with the following contents:  line1 Patient 123 45566 line2 Patient 432 line3 Patient 234 456 line4 Patient 321 line5   I am trying to select line 2 and line 4 with this pattern:  grep "Patient\s\d+\s" test.log # but this works testing at https://rubular.com/   Doesn't work nor does this:  grep "Patient\s\d+\n" test.log # but this works testing at https://regexr.com/47qd5   What am I doing wrong?
3235
I would like to get the multi pattern match with implicit AND between patterns, i.e. equivalent to running several greps in a sequence:  grep pattern1 | grep pattern2 | ...   So how to convert it to something like?  grep pattern1 &amp; pattern2 &amp; pattern3   I would like to use single grep because I am building arguments dynamically, so everything has to fit in one string. Using filter is system feature, not grep, so it is not an argument for it.    Don't confuse this question with:  grep "pattern1\|pattern2\|..."   This is an OR multi pattern match.
104616
I already managed to split the CSV file using this regex: "/,(?=(?:[^\"]\"[^\"]\")(?![^\"]\"))/"  But I ended up with an array of strings that contain the opening and ending double quotes. Now I need a regex that would strip those strings of the delimiter double quotes.  As far as I know the CSV format can encapsulate strings in double quotes, and all the double quotes that are already a part of the string are doubled. For example:  My "other" cat     becomes  "My ""other"" cat"  What I basically need is a regex that will replace all sequences of N doublequotes with a sequence of (N/2 - rounded down) double quotes.  Or is there a better way ? Thanks in advance.
7245
I would like to build a regexp in Java that would be passed in a FilenameFilter to filter the files in a dir.  The problem is that I can't get the hang of the regexp "mind model" :)  This is the regexp that I came up with to select the files that I would like to exclude   ((ABC|XYZ))+\w*Test.xml  What I would like to do is to select all the files that end with Test.xml but do not start with ABC or XYZ.  Could you please add any resources that could help me in my battle with regexps.  Thanks  The following resource explains a lot of things about regexp