DISQUS

DISQUS Hello! CodingExperiments.Com is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

CodingExperiments.Com

CodingExperiments.com is a site where I can (obviously) experiment with various demonstrations of code.
Jump to original thread »
Author

Sir, Please Step Away from the Regex. When to Use Regular Expressions in Code.

Started by Rishabh Mishra (possible248) · 1 year ago

Introduction

Regular expressions are several things. They are:
powerful.

useful.

sometimes overkill.
A difficult part for beginning programmers is when to use a regular expression in code. Sometimes, whipping up something with string functions is a better idea. You’re a smart coder if you can tell the difference from ... Continue reading »

2 comments

  • If you are going to write an article criticizing regex overuse, you might want a regex that matches your description.

    /^3.+/ does not simply mean 'start with 3'. It means 'start with 3 and one or more additional characters'.

    /^3.*/ is probably what you wanted.

    + means 'match the preceding element one or more times' whereas * means 'match the preceding element zero or more times'
  • Oh dear, you are correct.

    My apologies for the obvious sloppiness in writing the post. Much thanks given to you. I have corrected the post to reflect this.

Add New Comment

Returning? Login