i have a variable which stores the whole html content like :-
getcontent ="<table style="height: 1000px; ; width: 500px;" border="1"> <tbody> <tr> <td>[<span>Assignment(for) name</span>]</td> <td>[<span>Total No of staff-months of the assignment</span>]</td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </tbody> </table> "
now i want to convert the frst and the end double quote with single quote.
what regex can be used so that the getcontent converts to :-
'<table style="height: 1000px; ; width: 500px;" border="1"> <tbody> <tr> <td>[<span>Assignment(for) name</span>]</td> <td>[<span>Total No of staff-months of the assignment</span>]</td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </tbody> </table> '
Use anchors for the beginning and end of the string:
^represents the beginning of the string and$the end.This assumes that you actually have a string that contains a beginning end ending
", not a string that is (syntactically) enclosed in", in which case your input is not valid, due to unescaped"within the string.