L
L
leanid2012-11-02 16:48:27
*nix-like systems
leanid, 2012-11-02 16:48:27

Tool for processing a text file with regular expressions and substitution replacement?

I often meet a task at work: there is an xml file in which

<position x="100" y="100" />
and I need to work out all such or similar matches, for example, increase the x coordinate by 2.5 times. I want to find a universal solution for a whole class of such problems. Process some of the lines in the file according to a certain rule and generate a new file.

Answer the question

In order to leave comments, you need to log in

7 answer(s)
D
Dmitry Guketlev, 2012-11-02
@Yavanosta

Possibly en.wikipedia.org/wiki/Sed ?

W
Wott, 2012-11-02
@Wott

sed

A
agladkov, 2012-11-02
@agladkov

Plus the previous ones for sed and add awk to the answers , also a very powerful thing for processing text files.

D
drone76, 2012-11-03
@drone76

If handles, then Sublime text 2. Excellent search for regular expressions, with highlighting and replacement.

H
HEm, 2012-11-03
@HEm

some editors (pspad, notepad++ of those that I have installed, for example) can do this

D
Dmitry, 2012-11-03
@Tomasina

I use notepad++ for similar

S
Stdit, 2012-11-02
@Stdit

Word processors (perl, php, etc.). Yes, of course, programming text processing scripts is not exactly a “tool”, but it is unlikely that something can make such tasks easier and more automated. In addition to regular expressions, xml can be processed by a full-fledged xpath-aware handler (such as DOMDocument).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question