Tagged Questions
1
vote
2answers
78 views
Regex and piped commands with sed
I'm finding really hard to use sed command, plus I can't seem to find well written tutorials.
Let me say that I worked with regular expression in other languages (Python, JavaScript, Java), so that ...
0
votes
1answer
45 views
Help with understanding a regular expression
I have this regular expression \\..\\{3\\}$
I want to understand how this expression works to match a string. My thought is that it matches any 8 characters at the end of the line. Is that how this ...
3
votes
2answers
117 views
How to add a line in many files
I have many .html files and I need to add a meta tag after <head>'s start tag in each file.
How I can do that?
Can vim help me?
0
votes
1answer
259 views
Remove a block of lines between two patterns [duplicate]
Possible Duplicate:
Show only text between 2 matching pattern
In a bash script using sed how can I remove a block of lines beginning with -pattern a- and ending with -pattern b- where the ...
1
vote
4answers
335 views
Replace text between brackets
I'm using awk '{ gsub(/BAR|WIBBLE/, "FOO"); print }' to replace text in data like:
SOMETHING [BAR, WIBBLE]
SOMETHING [BAR]
This gives the desired result of:
SOMETHING [FOO, FOO]
SOMETHING [FOO]
...
2
votes
2answers
534 views
Replace the shortest match of a string pattern
I have this string:
update mytable set mycol=myvalue where mycol=yourvalue;
I need to convert it to:
insert into mytemp select * from mytable where mycol=youvalue;
I can accomplish it like this ...
3
votes
4answers
217 views
Sort input file by the results of a regex
I'd like to sort a file based on the results of a regex expression. For example, if I have the following property declarations in Obj-C
@property (nonatomic, strong) id <AlbumArtDelegate, ...
2
votes
1answer
205 views
How to join vCards lines
vCard uses a special way to split long lines: At 75 characters, insert a DOS newline and a space. Joining therefore means to replace all occurrences of the sequence "CR, LF, space" with an empty ...
2
votes
2answers
486 views
How to do a regex search in a UTF-16LE file while in a UTF-8 locale?
EDIT: Due to a comment Warren Young made, it made me realize that I was not clear on one quite relevant point. My search string is already in UTF-16LE order (not in Unicode Codepoint order, which is ...
2
votes
1answer
173 views
Delete repeated words between brackets inline
Our input looks something like
2012-04-17 [GBPGBP]
2012-04-13 [GBP GBP]
2012-04-13 [GBP]
2012-04-11 [GBPGBP]
2012-04-11 [GBP GBP]
2012-04-10 [GBPGBP]
2012-04-06 [GBP GBP GBP]
2012-04-17 ...
1
vote
1answer
274 views
Multiply certain numbers in a text -file by certain constant
I want an alternative solution to this jQuery hack, tasting a bit reinventing the wheel -- look I am sure I could do this with some one-liner using basic *ix tools. Look much easier and ...
9
votes
6answers
597 views
Text Manipulation Across multiple lines
I Have a file that has text like this:
AAAA
BBBB
CCCC
DDDD
1234
5678
9012
3456
EEEE
7890
etc...
And i want to match up the Alphabetic lines with the Numeric lines so they are like this:
...
3
votes
1answer
128 views
Character classes: construct my own
I want to construct my own character class in a script, then modify (and use) it, for example:
[:myclass:] contains a, *, \n (as linefeed) and [WHITESPACE].
I want to add all characters to ...
6
votes
4answers
12k views
Finding text between two specific characters or strings
Say I have lines like this:
*[234]*
*[23]*
*[1453]*
where * represents any string (except a string of the form [number]). How can I parse these lines with a command line utility and extract the ...
2
votes
2answers
881 views
What is the python equivalent of grep -v?
I like grep -v. I use it all the time. But I am also doing some text processing in python, and there is one crucial thing that I lack.
Usually, I use grep -v to take extraneous stuff out of text.
...