Tapatalk

Regular expression for using * with /* and */ to delete comments

Regular expression for using * with /* and */ to delete comments

2
NewbieNewbie
2

    May 11, 2011#1

    Hello All,

    Does anyone know what the regex in the replace function in UltraEdit 16.30 should be to delete comments from a file that start with /* and end with */? I tried "/***/" (without quotes) and it did not work.

    Thanks

    901
    MasterMaster
    901

      May 12, 2011#2

      With a Perl regular expression, you can do it this way:

      (?s)/\*.*\*/

      \* matches an asterisk. Since * is a special character, the \ is needed to escape the special functionality and match the actual character.

      .* matches everything in between. The . is a wildcard that matches any character. The * says to match as many characters as it can find. By default, the . wildcard doesn't match end-of-line characters and thus will only match characters within a single line.

      (?s) is a special switch that tells the regex engine that the . wildcard character should also match end-of-line characters.

      2
      NewbieNewbie
      2

        May 12, 2011#3

        Thanks, bulgrien.