473,395 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Regex - Matching Multiline Comments

3
Hi ,

I am a starter with perl on windows.
I need to match commented lines like below

/* comments
* comments
comments */

Whats the exact reg exp in windows perl script to use for this.

I tried
($parm eq "\/*.*\n")
$parm =~ \^\/*.*\n/

Please let me know if you have a solution.

Thanks
Anilga
Aug 29 '07 #1
4 3048
KevinADC
4,059 Expert 2GB
the * is a special character in a regexp, if you want to match it you must escape it:

Expand|Select|Wrap|Line Numbers
  1. if (/^\/\* \w+/)
matches: "/* comment"

but by looking at what you posted you either made a mistake or don't understand how to write a reular expression because this is incorrect:

Expand|Select|Wrap|Line Numbers
  1. $parm =~ \^\/*.*\n/
Aug 29 '07 #2
anilga
3
Hi,

Thanks for the comments. I tried this:

Expand|Select|Wrap|Line Numbers
  1. while ($parm = <FILE>) {
  2.  
  3.     if( $parm eq /^\/\* \w+/) {
  4.         next;
  5.     }
  6.     print $parm;
  7.  
and I couldn't match.
Aug 29 '07 #3
KevinADC
4,059 Expert 2GB
if( $parm =~ /^\/\* \w+/)
Aug 29 '07 #4
miller
1,089 Expert 1GB
You can probably use the following reference to get what you want. It will help if you get some understanding of regular expressions before using this.

perlfaq6 - How do I use a regular expression to strip C style comments from a file?

- Miller
Aug 29 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Masahiro Ito | last post by:
I have attached a block of text similar to the type that I am working with. I have been learning a lot about Regex - it is quite impressive. I can easily capture bits of info, but I keep having...
0
by: Andy | last post by:
Hi All I have a urgent problem with the regex object. I am currently reading in source code files (complete file including newline characters) as plain text into a string. i am then using a regex...
2
by: Mr.Clean | last post by:
I am working on modifying a syntax highlighter written in javascript and it uses several regexes. I need to add a language to the avail highlighters and need the following regexes modified to...
1
by: David Elliott | last post by:
I have an expression that works for single line but not multiline. What am I missing? expression = "<div(?<data1>.*?)>(?<data2>.*?)</div>"; MatchCollection mc = Regex.Matches(data, expression,...
2
by: Daniel Billingsley | last post by:
First, if MSFT is listening I'll say IMO the MSDN material is sorely lacking in this area... it's just a whole bunch of information thrown at you and you're left to yourself as to organizing it in...
2
by: Mortimer Schnurd | last post by:
Hi All, I am a VB 6 programmer who is now trying to learn C#. In doing so, I am trying to convert some of my VB modules to C#. I routinely user Reg Expressions in VB and am having some trouble...
8
by: Bob | last post by:
I need to create a Regex to extract all strings (including quotations) from a C# or C++ source file. After being unsuccessful myself, I found this sample on the internet: ...
6
by: Martin Evans | last post by:
Sorry, yet another REGEX question. I've been struggling with trying to get a regular expression to do the following example in Python: Search and replace all instances of "sleeping" with "dead"....
7
by: MrNobody | last post by:
I'm trying to do some regex in C# but for some reason linebreaks are causing my regex to not work. the test string goes like this: string ss = "<tagname...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.