Thread: Regex help again (sorry, I am bad at these)
'<p>Complete the attached lab and submit via dropbox</p>\r<p><a href="https://owncloud.porterchester.edu/HVACR/PCI_GasHeat/GasElectrical/HVACR1114_LAB_13A.pdf" title="Lab 13A">Lab 13A<\a>'
Need the final string to separate the "LAB_13A.pdf" from the rest of the URL by inserting a "&file=" in front of it. The final string should look like:
'<p>Complete the attached lab and submit via dropbox</p>\r<p><a href="https://owncloud.porterchester.edu/HVACR/PCI_GasHeat/GasElectrical/&file=HVACR1114_LAB_13A.pdf" title="Lab 13A">Lab 13A<\a>'
I have tried something like:
update pcilms_assign set intro=regexp_replace(intro, '/([^/]*)\" title=$', '&files=\1') where intro like '%https://owncloud.porterchester.edu%' and course=18 and id=55413;
and the result puts the &file= in the wrong place (at the end of the whole string).
Any suggestions?
Thanks!
-Chris
On Mon, Dec 28, 2015 at 8:10 PM, Christopher Molnar <cmolnar@ourworldservices.com> wrote:
Any suggestions?
select regexp_replace('<p>Complete the attached lab and submit via dropbox</p>\r<p><a href="https://owncloud.porterchester.edu/HVACR/PCI_GasHeat/GasElectrical/HVACR1114_LAB_13A.pdf" title="Lab 13A">Lab 13A<\a>', '/([^/]*)\" title=', '/&file=\1" title=')
UPDATE your_table
SET your_column = REPLACE (your_column, 'HVACR1114_LAB_13A.pdf', '&file=HVACR1114_LAB_13A.pdf')
WHERE <whatever_expression is needed>;
Sorry to have to ask the experts here for some regex assistance again. I am admittadly awful with these and could use some help.Have the following string (this is an example) that needs to be changed. Need to use a search and replace because the links across over 200K records are similar but not the same.'<p>Complete the attached lab and submit via dropbox</p>\r<p><a href="https://owncloud.porterchester.edu/HVACR/PCI_GasHeat/GasElectrical/HVACR1114_LAB_13A.pdf" title="Lab 13A">Lab 13A<\a>'
Need the final string to separate the "LAB_13A.pdf" from the rest of the URL by inserting a "&file=" in front of it. The final string should look like:
'<p>Complete the attached lab and submit via dropbox</p>\r<p><a href="https://owncloud.porterchester.edu/HVACR/PCI_GasHeat/GasElectrical/&file=HVACR1114_LAB_13A.pdf" title="Lab 13A">Lab 13A<\a>'
I have tried something like:
update pcilms_assign set intro=regexp_replace(intro, '/([^/]*)\" title=$', '&files=\1') where intro like '%https://owncloud.porterchester.edu%' and course=18 and id=55413;
and the result puts the &file= in the wrong place (at the end of the whole string).
Any suggestions?
Thanks!
-Chris
--
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

'<p>Complete the attached lab and submit via dropbox</p>\r<p><a href="https://owncloud.porterchester.edu/HVACR/PCI_GasHeat/GasElectrical/HVACR1114_LAB_13A.pdf" title="Lab 13A">Lab 13A<\a>'
update pcilms_assign set intro=regexp_replace(intro, '/([^/]*)\" title=$', '&files=\1') where intro like '%https://owncloud.porterchester.edu%' and course=18 and id=55413;
and the result puts the &file= in the wrong place (at the end of the whole string).
Will this work?Your mileage may vary because you have not stated your VERSION of PostgreSQL or your O/S.
UPDATE your_table
SET your_column = REPLACE (your_column, 'HVACR1114_LAB_13A.pdf', '&file=HVACR1114_LAB_13A.pdf')
WHERE <whatever_expression is needed>;
Will this work?Your mileage may vary because you have not stated your VERSION of PostgreSQL or your O/S.
UPDATE your_table
SET your_column = REPLACE (your_column, 'HVACR1114_LAB_13A.pdf', '&file=HVACR1114_LAB_13A.pdf')
WHERE <whatever_expression is needed>;What part of your solution is version or O/S dependent?David J.
--
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

Hello Chris,
On Mon, Dec 28, 2015 at 8:10 PM, Christopher Molnar <cmolnar@ourworldservices.com> wrote:Any suggestions?
This seems to works:
select regexp_replace('<p>Complete the attached lab and submit via dropbox</p>\r<p><a href="https://owncloud.porterchester.edu/HVACR/PCI_GasHeat/GasElectrical/HVACR1114_LAB_13A.pdf" title="Lab 13A">Lab 13A<\a>', '/([^/]*)\" title=', '/&file=\1" title=')Regards,Félix