Regexp FindAllStringSubmatch returns an array of strings with []

When I use FindAllStringSubMatch it returns the matched substring enclosed in brackets. For example if I am matching the string “this is a test” what is returned is “[this is a test]”. And the same for other substrings. They all have [ some text ]. Is there a way to eliminate those brackets without yet another regex to remove them?

Any help is appreciated and it’s possible this is a simple one since I am new to golang.

The function you mention doesn’t do this. I expect you are looking at brackets added by fmt.Println when printing slices, or something that is present in your input.

It’s is fmt.println and they are slices. Perhaps if I just write it back out to stdout another qay I can get what I want. Thanks. It did not occur to me it might be the print function.

Bob

Get Outlook for Android

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.