I have a little interesting issue here I have a plain text URL that is coming from Excel and I have to convert it to a unique URL with a unique body. Here is the regex code for javascript:
text = text.toString (). Replace (/ = hyperlink \ (([[@ \\\ w \ s \ (-) - \. \ /] +) \) / G, "& lt; a href = 'file: /// $ 1' & Gt; $ 1 & lt; / a & gt; "); For example, the text is: = hyperlink ("\\ share \ folder \ log \") 2013 \ 13-05-13 \ 13-05-13.txt ")
regex turns it on
& lt; A href = "file: /// \\ share \ folder \ log \ 2013 \ 13-05-13 \ 13-05-13.txt" & gt; \\ share \ folder \ log \ 2013 \ 13-05-13 \ 13-05-13.txt & lt; / A & gt; However, I need to have internal HTML which is just the name of the text file:
& lt; A href = "file: /// \\ share \ \ 13-05-13 \ 13-05-13.txt" & gt; 2013 folder \ log; 13-05-13.txt & lt; / A & gt; To make this case more complicated, the original text that is being done through regedx is not a single phenomenon. This is a complete spreadsheet that contains 100 rows, in which it is included. Therefore, regex will match and replace these 100 strings in a string.
Hopefully it is possible to do this on a whole string in a string, but I think that I can loop through each line the first string ...
If there is no way to do this with a regex engine, then what do you think is the best way? (No PHP / Python / server side. Just Javascript, HTML, Jquery, etc.).
I think you can use this regex:
= Hyperlink \ ("([[@ \\\ w \ s \ (\) \ - \. \ / + + \\ ([^" +] +) '"\) And replace this new one:
& lt; a href = "file: /// $ 1" & gt; $ 2 I'm not sure how your regex was working, but I added quotation marks in regex and single quotes were substituted with double quotes in the replacement.
No comments:
Post a Comment