How to select an image link text (html) and delete everything else with Regex?

Asked

Viewed 96 times

0

I am working with a CSV file (XML type), I am using a google spreadsheet to be able to clean the data, I would like to edit a set of cells making a selection of an image link in html and delete the rest of the cell using Regex.

The google spreadsheet has the feature of interpreting regular expressions(regex) in the location and replacement of an item.

An example of the image link is as follows:

src="https://exemplo.files.wordpress.com/2018/04/30656289_1739197086123960_7879125475971301376_o.jpg"

I would like to always locate the src="https://exemplo.files.wordpress.com/

Then select the rest of the sentence until the quotation marks close. In this example would be:

/2018/04/30656289_1739197086123960_7879125475971301376_o.jpg

Finally delete all cell phone content and keep only this part of the text:

/2018/04/30656289_1739197086123960_7879125475971301376_o.jpg

Some wise man can help me?

  • There’s no way to test it now, but try src\="https:\/\/exemplo.files.wordpress.com(.*?)"

1 answer

2

Use the expression:

src\="https:\/\/exemplo\.files\.wordpress\.com(.*?)"

in the replace field put $1 which is equivalent to group 1: (.*?)

You can test the expression on regex101.com

  • 1

    The . other than the group, they wouldn’t be \. ?

  • True, I’d forgotten.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.