0

How to replace a string followed by any number with NULL .

Example [tag:1234:test][tag:5678:sql]

Here i need to replace tag:1234: with null

Result should be : [test][sql]

** tag string will be constant ,Numbers will vary .

Kindly help me on this.

1
  • Have you tried anything? Commented Feb 24, 2016 at 10:02

1 Answer 1

1

Here you go:

SELECT regexp_replace('[tag:1234:test][tag:5678:sql]', '\\[tag:\\d+:([^\\]]+?)\\]', '[\\1]', 'g')

It's done by using regexp_replace function with suitable regular expression and g (global) flag for replacing all matches.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for Quick Reply ! Works Fine !
@user3007361 -- if pumbo's answer satisfies your original question, please mark it as correct so that future people with a similar problem will know it met your needs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.