Reputation: 415
This is the content.
<ext-link ext-link-type="uri" xlink:href="http://<xref rid="x0026;AN=15230473">http://web.ebscohost.coms/ehost/detail&#x003F;sid=d1f06770-cd74-4496-ae7b-7689ed05c6c4%40sessionmgr10&#x0026;vid=1&#x0026;hid=23&#x0026;bdata=JnNpdGU9ZWhvc3QtbGl2ZQ%3d%3d&#x0023;db=ufh&#x0026;AN=15230473</xref>" link-type="url">
I want capture inside xlink:href="http://<xref rid="x0026;AN=15230473">http://web.ebscohost.coms/ehost/detail&#x003F;sid=d1f06770-cd74-4496-ae7b-7689ed05c6c4%40sessionmgr10&#x0026;vid=1&#x0026;hid=23&#x0026;bdata=JnNpdGU9ZWhvc3QtbGl2ZQ%3d%3d&#x0023;db=ufh&#x0026;AN=15230473</xref>
"
with double quotes.
I try this but cant get the which i need.
<ext-link(?: [^>]+)? xlink:href="([^"]+)"[^><]*>
Upvotes: 0
Views: 101
Reputation: 174844
Use \S+
to match one or more non-space characters.
<ext-link[^>]+? xlink:href="(\S+)"
Upvotes: 1
Reputation: 67988
xlink:href=("(?:(?!<\/xref>).)*<\/xref>")
Try this.grab the capture.See demo.
http://regex101.com/r/zU7dA5/6
Upvotes: 0
Reputation: 5308
perl -pe 's/^.*xlink:href=\"//; s/\">$//' file
Example:
sdlcb@Goofy-Gen:~/AMD/SO$ cat file
<ext-link ext-link-type="uri" xlink:href="http://<xref rid="x0026;AN=15230473">http://web.ebscohost.coms/ehost/detail&#x003F;sid=d1f06770-cd74-4496-ae7b-7689ed05c6c4%40sessionmgr10&#x0026;vid=1&#x0026;hid=23&#x0026;bdata=JnNpdGU9ZWhvc3QtbGl2ZQ%3d%3d&#x0023;db=ufh&#x0026;AN=15230473</xref>">
sdlcb@Goofy-Gen:~/AMD/SO$ perl -pe 's/^.*xlink:href=\"//; s/\">$//' file
http://<xref rid="x0026;AN=15230473">http://web.ebscohost.coms/ehost/detail&#x003F;sid=d1f06770-cd74-4496-ae7b-7689ed05c6c4%40sessionmgr10&#x0026;vid=1&#x0026;hid=23&#x0026;bdata=JnNpdGU9ZWhvc3QtbGl2ZQ%3d%3d&#x0023;db=ufh&#x0026;AN=15230473</xref>
Upvotes: 0