regular expression 'or-ed' - doesnt work!

  • Thread starter Thread starter Jonathan Sion
  • Start date Start date
J

Jonathan Sion

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)|(create\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!
 
Jonathan said:
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)|(create\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.
 

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