• Post Reply Bookmark Topic Watch Topic
  • New Topic

to extract substring using regex  RSS feed

 
ashwini hirlekar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have one column "category" which contain data like

`"Failed extract of third-party root list from auto update cab at: <http://ctldl.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootstl.cab> with error: The data is invalid."`

I need to select url part in between `" < > "` sign of category column.

how to do this usign regex?
Please help.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16058
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it absolutely required to use a regular expression for this?

It's less complicated to find the first '<' and the last '>' in the string and take the text in between, using methods of class String.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any question of the form "How do I do X by using Y?" is flawed by definition. The correct question would be "What is the best way to do X?"

The reason is that more often than not, Y is a TERRIBLE technology to do X. Can it be done? possibly - if you abuse it, or write something terribly complicated and hard to read. And it may NOT be possible.

Not possible:
How do I draw a square using my telephone?
How do I fly to the moon with a duck?

Very hard, and probably not the best way to do it:
How do I drive a wood screw into a board using a hammer?
How do I get from the U.S. to Mainland China with a canoe?
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:
It's less complicated to find the first '<' and the last '>' in the string and take the text in between, using methods of class String.


Certainly - and one of the String methods is replaceFirst() which, using a regular expression, allows one to find the first '<' and the following '>' and replace everything outside of this region by the empty string. I suspect that this is not the approach using the String class that you had in mind.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!