Reputation: 688
I know I should dedicate time to learn regular expressions but meanwhile help me please.
With javascript I want to convert this:
http://www.url.pdf (or https://)
to
<iframe src="http://www.url.pdf" width="500" height="400"></iframe>
Thank you!
Upvotes: 0
Views: 130
Reputation: 72965
Use this:
(https?:\/\/\S*?\.pdf)
Example: http://regex101.com/r/vJ2aY9
Will convert:
http://www.url.pdf
https://www.otherurl.pdf
To:
<iframe src="http://www.url.pdf" width="500" height="400"></iframe>
<iframe src="https://www.otherurl.pdf" width="500" height="400"></iframe>
...by way of the capture group and backreference $1
.
Footnote: generally speaking, you should show at least a minimal effort when posting a question. A good resource to learn about regular expressions is http://regular-expressions.info, or you can even use regex101 to play around and learn what each special character does.
Upvotes: 1