Answer the question
In order to leave comments, you need to log in
Why does sed handle occurrences (regexes) incorrectly?
Hello everybody!
Task:
There is a line with tags, you need to extract Commanda1 and Comanda2 from it.
</td><td class="tdteamname2">Comanda1</td><td class="tdteamname2">Comanda2</td>
[[email protected] share]$ cat 2str | sed 's/me2">/---/'
</td><td class="tdteamna---Comanda1</td><td class="tdteamname2">Comanda2</td>
[[email protected] share]$ cat 2str | sed 's/me2">/---/2'
</td><td class="tdteamname2">Comanda1</td><td class="tdteamna---Comanda2</td>
[[email protected] share]$ cat 2str | sed 's/<.*me2">/---/'
---Comanda2</td>
Answer the question
In order to leave comments, you need to log in
What you are looking for is called "non-greedy matching" or "non-greedy searching".
As far as I know, sed doesn't have it.
If your number of characters (read - tags) is always the same, it's easier not to bother with regular expressions, but simply bite off the necessary parts of the string, for example, using tr
.
once.
https://github.com/EricChiang/pup
2. if you need to parse something complex but not on an ongoing basis, even a schoolboy will learn.
https://chrome.google.com/webstore/detail/web-scra...
3. special programs xmlstarlet, html-xml-utils .... and so on are generally better suited for this
4. 1 variable 2 variable
cut -d '>' -f3 111.txt | sed 's/<\/td//g'
cut -d '>' -f5 111.txt | sed 's/<\/td//g'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question