hi all, recently ran into a really hard problem for me:

i have an sql command with something like this

SELECT xxxxx FROM xxxxxx WHERE filter LIKE '[A]'

what i would like to do is substitute [ with [[] on the condition that it is after a LIKE and is within " ' " and " ' " directly after the like. regex comes to mind, but i really don't know how to start.

i obviously can't use string.replace because there's that condition that i need to meet.

what i would like to specify is that when i find a LIKE operator, look for two " ' ", if they are found, look between them to find [, if it is found, replace it with [[].

will this be possible? or can someone suggest a brighter idea.

thanks.

Recommended Answers

All 4 Replies

Sure, thats possible.

well i think all you want is a replace command and you don't have to use regex...well here's a SQL replace query to substitute part of field data:
update emp set department='Marketing' where department='Sales'

no i can't use a replace command since i'm not replace every [. i only want to replace those coming after like.

going back to using regex, can you give me an example on how it is done? i'm not really sure where to start as i'm not really familiar with it.

thanks in advance.

Well. As you havent even shown any signs of trying - read the regex help, show some code, you tell us what you have and how its not doing what you want, then we'll try and steer you in the right direction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.