I have a VueJS application that contains forms that are pre-populated with data. The textarea element contains some data as shown on the UI
NOTE: (Sorry, I don't have enough rep points to attach a screenshot yet):
Screenshot of quoted UI text area element
I cannot modify the way the backend provides data.
So, is there a good way to remove the first and last quotes from a string? I don't want to touch the inner text in case the user adds quotes in it.
The expected output of'Hello World,welcome to "fooWorld!"' should be Hello World,welcome to 'fooWorld!'
Here is a real-life example of how I use data in a SPA:
data() { return { entryNotes: this.post.entryNotes //<--- this is the data I need to format } }
How to remove opening and closing quotes using fast regex?
The first regular expression looks for the beginning of the string (represented by ^), then for quotes. The second regex looks for quotes and then for the end of the string (the end of the string is represented by $).
You can also do this:
This looks for the beginning of the string (^), followed by a ", but the ? makes it optional. Then the brackets capture . , which means match anything. The ? before the end of the bracket means stop matching as soon as possible. Then it says to look for quotes, but the next question mark says "maybe" and then looks for the end of the string ($).