0
$\begingroup$

This question already has an answer here:

I hope you can help me right now, I am working on lexical analyzer for C language, I am bit confuse bout the regular expression of C style comments. a regex which can handle both single and multiline comments.

$\endgroup$

marked as duplicate by Raphael Nov 4 '14 at 16:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ If this were not already a duplicate, I'd ask: what have you tried and where did you get stuck? $\endgroup$ – Raphael Nov 4 '14 at 16:32
  • $\begingroup$ Could you be more precise? What is your problem ? $\endgroup$ – babou Nov 4 '14 at 16:39
  • $\begingroup$ @Raphael there are so many answers to them and none of them is working for me, i want a single regex which can handle both single and multiline comments. $\endgroup$ – Noor Nov 4 '14 at 16:47
  • $\begingroup$ @babou my problem is I have to submit assignment withing 2 hrs! well joke apart my regex is not handling both single and multiline comments in C, is this regex alright = (/*.*?*/)|//.*?\n " $\endgroup$ – Noor Nov 4 '14 at 16:52
  • $\begingroup$ @Noor Your homework is your own to do, otherwise you'll learn little to nothing. That said, if you have regular expressions (!= regex, btw) $r_1$ and $r_2$ for both types, joining them like $r_1 + r_2$ should do the trick. (What do you match; the whole text? Lines?) $\endgroup$ – Raphael Nov 4 '14 at 18:28

Browse other questions tagged or ask your own question.