Jan-23-2017, 11:35 AM
I am coding a program in Python to fetch comments in a C program( both single and multiline). What regular expression should be used for this?
Regular expression to fetch comments in C using Python
|
Jan-23-2017, 11:35 AM
I am coding a program in Python to fetch comments in a C program( both single and multiline). What regular expression should be used for this?
Jan-23-2017, 04:41 PM
What have you tried?
I am having issues with lines containing the code and the comment like:
printf("hai) // prints hai c = c + 1 /* htshgbxbvxvbxvxxzv fgdhdhgdghfcncnbc arabcnbchcjc */I am not able to categorize the kind of characters that can come up before the comment in 1 and 2. ( . )* doesn't help. Is there any other way to sum up them all rather than specifying them individually?
Jan-24-2017, 09:04 AM
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Well, chek if there is '//' or '*/' in the row. If it is, split the row by '//' or '*/', get the text with in the list which appers to be the comment ( this sould be row[1] ). Then if that is '*/' just take every row until you find '*/'. This is step by step. You can rid off the white space characters using str.strip() function. If you need to.
|
|