Forum Academy Marketplace Showcase Pricing Features

How to remove first and last character of a string?

So I am using formatted as JSON safe and it adds " char on the start and end of string which is causing me errors, I dont want to find and replace all " characters but instead remove just the " on the first and last of the string.


Hi there, @hirayaleads… I don’t pretend to know jack about regex, but I was able to find patterns that remove the first character and the last character of a string. So, you could use the following patterns in two find and replace operators.

Hope this helps.


P.S. If your next question is, “But what if the first and last characters aren’t quotation marks and I don’t want to remove them?”, well, maybe someone else can help or you’re on your own there because, as I mentioned, I don’t pretend to know jack about regex. :slight_smile:

how do you come up with those characters in the first place? man, i dont know where those coming from but im going to use it. looking at regex now for a few hours and man it is the most hardest part for me.


There’s only one true way… Google and trial and error, of course. :slight_smile:

1 Like

works perfectly!

1 Like

If you want to replace the first and last characters, but only if they are quotes, the regex to use are:

  • ^" selects the quotes if it is the first character
  • "$ selects the quotes if it’s the last character




This topic was automatically closed after 70 days. New replies are no longer allowed.