|  | Posted by Erland Sommarskog on 09/19/05 00:47 
NickName (dadada@rock.com) writes:> This is not SQL Server database problem, however, net search has failed
 > to generate a solution to the problem, I'm trying my luck at this NG
 > now.
 >
 > Problem,  remove the special character, [ from text.
 > e.g. text =
 > "this is [1] and [stuff] and some [2] and hat [3] and dog"
 >
 > Desired result =
 > "this is 1 and [stuff] and some 2 and hat 3 and dog"
 >
 > I know [[:digit:]] would find all the instances of digits inside
 > brackets such as [1], [2], [3].  However, I don't know how to get rid
 > of the special characters of [ and ].
 >
 > Any regular expression expert out there?
 
 Since you did not specify which regular expressions you are using, I'm
 taking the liberty to answer with the regexps I know, that is those of
 Perl. In Perl you would say:
 
 s/\[([0-9]+)\]/\1/g
 
 The \[ means [, that is \ is an escape charactter. () is for grouping,
 and \1 refers back to this paren.
 
 I have only seen glimpses of the regexps in .Net, but it appears to be
 similar to Perl. There might be different rules for when you need \
 though. In Textpad that I use, I would have to say \( and \)to use parens
 for grouping.
 
 --
 Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
 
 Books Online for SQL Server SP3 at
 http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
  Navigation: [Reply to this message] |