Regex pattern for c style comments
Today, I am going to discuss my attempts to parse c style comments. For example, //This is a comment<br></br> ** /***This is also<br></br> *** a comment ***/ ** Initially, I came up with a regex for /…/ style comments : <strong>/*.**/</strong> Well, the above expression was not able to parse comments like: <br></br> /*** This is a comment ***/<br></br>``` I googled and came across [http://ostermiller.org/findcomment.html](http://ostermiller.org/findcomment.html) where I found the regex: `<strong>/*(.|[rn])*?*/</strong>` This was able to match comments like the above one. But it’d also match the following /*…*/ comments which are not really comments: s = “This is a string: /* with a comment /”; //comment1 / foo(); //comment2 */ ``` ...