Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mcp111
Starting Member
44 Posts |
Posted - 2014-04-28 : 15:16:32
|
I want a regular expression in SQL Management studio to replace everything from the middle blank to end of the line by blank see bolded example. Should do this for the whole snippet of code posted here
[drvrsk_endorsementEffectiveDate] [datetime] NULL, [drvrsk_changeDate] [datetime] NULL, [drvrsk_number] [nvarchar](50) NULL, [drvrsk_type] [nvarchar](100) NULL, [drvrsk_typeDescription] [nvarchar](256) NULL, [drvrsk_firstName] [nvarchar](150) NULL, [drvrsk_middleName] [nvarchar](150) NULL, [drvrsk_lastName] [nvarchar](150) NULL, [drvrsk_licenseNumber] [nvarchar](70) NULL, [drvrsk_licenseState] [nchar](2) NULL, [drvrsk_licenseClass] [nvarchar](2) NULL,
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-04-28 : 15:55:22
|
I don't understand what you want. What do you want to replace it with? Is it stored in a variable?
Tara Kizer SQL Server MVP since 2007 http://weblogs.sqlteam.com/tarad/ |
 |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-04-28 : 16:13:10
|
Not sure if this is what you want. I searched for ^{\[:i\]}.* and replaced it with \1, |
 |
|
mcp111
Starting Member
44 Posts |
Posted - 2014-04-28 : 16:33:35
|
I want to replace with blank
eg
[drvrsk_endorsementEffectiveDate] [datetime] NULL,
will be replaced by
[drvrsk_endorsementEffectiveDate]
so the bolded portion is replaced by blanks
Similarly for all the other lines
so the end result should be
[drvrsk_endorsementEffectiveDate] [drvrsk_changeDate] [drvrsk_number] [drvrsk_type] [drvrsk_typeDescription] [drvrsk_firstName] [drvrsk_middleName] [drvrsk_lastName] [drvrsk_licenseNumber] [drvrsk_licenseState] [drvrsk_licenseClass]
Hope this helps.
quote: Originally posted by tkizer
I don't understand what you want. What do you want to replace it with? Is it stored in a variable?
Tara Kizer SQL Server MVP since 2007 http://weblogs.sqlteam.com/tarad/
Regards
Partha Mandayam |
 |
|
mcp111
Starting Member
44 Posts |
Posted - 2014-04-28 : 16:35:36
|
No - that selects the entire line
See my earlier reply to @tkizer
quote: Originally posted by gbritton
Not sure if this is what you want. I searched for ^{\[:i\]}.* and replaced it with \1,
Regards
Partha Mandayam |
 |
|
mcp111
Starting Member
44 Posts |
Posted - 2014-04-28 : 16:38:11
|
Actually it does work - thanks
Can you please explain what this regular expression means?
quote: Originally posted by gbritton
Not sure if this is what you want. I searched for ^{\[:i\]}.* and replaced it with \1,
Regards
Partha Mandayam |
 |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-04-30 : 07:45:35
|
It means:
^ matches beginning of line { begin a grouping expression \[ match an opening bracket :i match on a valid identifier \] match on a closing bracket } end grouping expression .* match anything else that follows
\1 refers to the group matched by the grouping expression above.
Have you read the documentation on this?
http://msdn.microsoft.com/en-us/library/2k3te2cs.aspx |
 |
|
|
|
|