Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

sed question

Hi,

how can I tell sed to substitute the SHORTEST matching string and not the longest?

Example:
echo "<BR>Hello</FONT>test" | sed "s/.*>//;"

--> "test" is the output but I just wanted the string until the first ">" be replaced.

Thanks
0
hitzeu
Asked:
hitzeu
  • 4
  • 2
  • 2
  • +2
1 Solution
 
biraCommented:
echo "<BR>Hello</FONT>test" |rev| sed "s/.*>//;"|rev
0
 
ozoCommented:
echo "<BR>Hello</FONT>test" | sed "s/[^>]*>//;"
0
 
hitzeuAuthor Commented:
Works, thanks.
And what if I wanted to filter out all TAGS inside a string ?

echo "<TAG1>text text text <TAG2> text_end" | sed .... ?
---> "text text text   text_end"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ahoffmannCommented:
echo "<TAG1>text text text <TAG2> text_end" | sed -e 's/<[^>]*>//g'
0
 
hitzeuAuthor Commented:
can't thank you enough....
0
 
mrn060900Commented:
what about the points for ahoffmann?
0
 
hitzeuAuthor Commented:
good question..... he does not post answers, "just" comments.

Ahoffmann, how can I reward you :-)
0
 
mrn060900Commented:
just accept his comment as the answer.
0
 
hitzeuAuthor Commented:
oops
0
 
ahoffmannCommented:
no more comments neede. Points arrived ;-)
Thanks.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now