Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Reg Exp for digits
Hi,

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 ge
t rid
of the special characters of [ and ].

Any regular expression expert out there?

Thanks.

Don


Report this thread to moderator Post Follow-up to this message
Old Post
NickName
09-19-05 01:23 AM


Re: Reg Exp for digits
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 groupin
g,
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/techin.../2000/books.asp


Report this thread to moderator Post Follow-up to this message
Old Post
Erland Sommarskog
09-19-05 01:23 AM


Re: Reg Exp for digits
> 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"

Using the Zeus editor:

http://www.zeusedit.com

These are the search and replace regular expresions:

Search: (\[)([0-9]+)(\])
Replace: \2

Note: Zeus is shareware (45 day trial).

Jussi Jumppanen
Author: Zeus for Windows


Report this thread to moderator Post Follow-up to this message
Old Post
jussij@zeusedit.com
09-19-05 01:23 AM


Re: Reg Exp for digits
Erland,

I appreciate your response, unfortunately I'm not using Perl.

Don


Report this thread to moderator Post Follow-up to this message
Old Post
NickName
09-19-05 08:24 AM


Re: Reg Exp for digits
Jussi,

Thanks for the response, I think your tool seems clever, and yet I'm
trying not to introduce many tools within one project.

Don.


Report this thread to moderator Post Follow-up to this message
Old Post
NickName
09-19-05 08:24 AM


Re: Reg Exp for digits
NickName (dadada@rock.com)  writes:
> I appreciate your response, unfortunately I'm not using Perl.

If in you insist on not telling what you use, the responses may not always
be applicable.

Anyway, I hoped that you would be able to translate the Perl stuff to
whatever you are using.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp


Report this thread to moderator Post Follow-up to this message
Old Post
Erland Sommarskog
09-19-05 08:24 AM


Re: Reg Exp for digits
NickName wrote:

> Thanks for the response, I think your tool seems clever, and
> yet I'm trying not to introduce many tools within one project.

The good thing is the regexp's that I posted are just standard
unix style regexp's so they should work with any tool that can
handle these type of regexp's.

Jussi Jumppanen
Author: Zeus for Windows
http://www.zeusedit.com


Report this thread to moderator Post Follow-up to this message
Old Post
jussij@zeusedit.com
09-20-05 01:24 AM


Re: Reg Exp for digits
Shoot, you're tricky, now that you say it's sort of generic, I tried it
and it works nice, thanks.


Report this thread to moderator Post Follow-up to this message
Old Post
NickName
09-20-05 08:24 AM


Re: Reg Exp for digits
Erland,

Jussi's solution solved the problem.  You seem a very kind person, if
one day I travel to Sweden and you're available, I would love to buy
you a beer.

Kind regards,

Don Li


Report this thread to moderator Post Follow-up to this message
Old Post
NickName
09-20-05 08:24 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 01:54 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006