filter string over regular expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello,

in a string which i read from a textfile there are some lines, which must be
eliminated.
The content of the stringvariable is for example :

myString="
--comment 1
Update .....
--comment 2 .......
SELECT DISTINCT .....
...."

how can i eliminate all the comment lines marked with --
so that i get

myString="
Update .....
SELECT DISTINCT .....
...."

The new string has no more lines with --

thanks
Xavier
 
Hi Xavier,

The following will match any line that begins with "--"

(?m)^--.*\r*\n

You can use Regex.Replace to take them out.
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
i tryed to use the match with the folowing function

vInputString = Regex.Replace(vInputString, "^--.*\r*\n", "")

where the inputstring is the value what i get from the textfile and has the
value
vInputString ="
--comment 1
select * from Table1 where AreaId=1001
--other comment

--comment 2
Select * from table 2
--GO--
"

I want to eliminate all lines what beginns with --
The result must be in my example only
vInputString ="
select * from Table1 where AreaId=1001
Select * from table 2"



but i did not work

any idea?

thanks
 
but i did not work

Apparently not.
any idea?

Try using the WHOLE Regular Expression I gave you:

(?m)^--.*\r*\n

The following is a link to a FREEWARE Regular Expression Building and
Testing tool that works quite well:

http://www.ultrapico.com/Expresso.htm

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
yes, i also noticed this...
Now it's all fine

thanks, for your help
Xavier
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top