TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Notices

Reply
 
Thread Tools Display Modes
Old 11-12-2007, 12:15 PM   #1
Jonathan Sion
Guest
 
Posts: n/a
regular expression 'or-ed' - doesnt work!

Hi,
I'm totally new to this forum, and relatively new to regexp. What I am
looking for is an expression that in a pieace of TSQL code, will move
the function header, and then all whitespaces in it. I came up with
this one:

\s||(^(.|\n)*((create\s*view)|(create\s*proc)|(cre ate\s*function)|
(create\s*trigger)))

So, its basically, 'all whitespaces, or anything that's at the
beginning of the header (create [entity type]... that's TSQL)

I think this works ok, though I haven't tested much. (Does it make
sense?) now my question is, when I change the order:
(^(.|\n)*((create\s*view)|(create\s*proc)|(create\ s*function)|(create
\s*trigger)))||\s

The \s doesn't work! It doesn't clear out whitespaces. Now why is
that? If its this-or-that, why does the order matters? I have a
feeling that fundamentally I misunderstood something....

Thanks!

  Reply With Quote
Old 11-12-2007, 12:17 PM   #2
Lasse Vågsæther Karlsen
Guest
 
Posts: n/a
Re: regular expression 'or-ed' - doesnt work!

Jonathan Sion wrote:
> Hi,
> I'm totally new to this forum, and relatively new to regexp. What I am
> looking for is an expression that in a pieace of TSQL code, will move
> the function header, and then all whitespaces in it. I came up with
> this one:
>
> \s||(^(.|\n)*((create\s*view)|(create\s*proc)|(cre ate\s*function)|
> (create\s*trigger)))
>
> So, its basically, 'all whitespaces, or anything that's at the
> beginning of the header (create [entity type]... that's TSQL)
>
> I think this works ok, though I haven't tested much. (Does it make
> sense?) now my question is, when I change the order:
> (^(.|\n)*((create\s*view)|(create\s*proc)|(create\ s*function)|(create
> \s*trigger)))||\s
>
> The \s doesn't work! It doesn't clear out whitespaces. Now why is
> that? If its this-or-that, why does the order matters? I have a
> feeling that fundamentally I misunderstood something....
>
> Thanks!
>


Perhaps I'm misunderstanding what you want to do, but \s doesn't "clear
out whitespaces". \s matches 1 whitespace character.

Also, why do you have two bars there, ie. ||\s or \s|| ? (perhaps that's
some regex syntax I'm unfamiliar with).

Also, try explaining what it is you want to match, instead of just
asking wether your current solution is right. You mention you want to
"move" the function header. Move how/where?

If you could give us short-but-complete code and example input and
output, that would probably go a long way.

--
Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
  Reply With Quote
Old 11-12-2007, 12:20 PM   #3
Lasse Vågsæther Karlsen
Guest
 
Posts: n/a
Re: regular expression 'or-ed' - doesnt work!

Jonathan Sion wrote:
> Hi,
> I'm totally new to this forum, and relatively new to regexp. What I am
> looking for is an expression that in a pieace of TSQL code, will move
> the function header, and then all whitespaces in it. I came up with
> this one:
>
> \s||(^(.|\n)*((create\s*view)|(create\s*proc)|(cre ate\s*function)|
> (create\s*trigger)))
>
> So, its basically, 'all whitespaces, or anything that's at the
> beginning of the header (create [entity type]... that's TSQL)
>
> I think this works ok, though I haven't tested much. (Does it make
> sense?) now my question is, when I change the order:
> (^(.|\n)*((create\s*view)|(create\s*proc)|(create\ s*function)|(create
> \s*trigger)))||\s
>
> The \s doesn't work! It doesn't clear out whitespaces. Now why is
> that? If its this-or-that, why does the order matters? I have a
> feeling that fundamentally I misunderstood something....
>
> Thanks!
>


Perhaps I'm misunderstanding what you want to do, but \s doesn't "clear
out whitespaces". \s matches 1 whitespace character.

Also, why do you have two bars there, ie. ||\s or \s|| ? (perhaps that's
some regex syntax I'm unfamiliar with).

Also, try explaining what it is you want to match, instead of just
asking wether your current solution is right. You mention you want to
"move" the function header. Move how/where?

If you could give us short-but-complete code and example input and
output, that would probably go a long way.

--
Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
  Reply With Quote
Reply

Thread Tools
Display Modes




New To Site? Need Help?

All times are GMT +5.5. The time now is 07:17 PM.


vBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2009, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional