DEV Community

Sara Schoonover
Sara Schoonover

Posted on

.match vs .gsub

Today I played around with .match and .gsub to learn the differences between the two. Instinctively, I always lean toward using .match even though I have to write extra logic to solve some exercises with it, so I used gsub today and leaned into being uncomfortable. I discovered that gsub is more efficient with replacing characters you want replaced and match is better for finding out if a pattern exists.

Top comments (0)