Re: Find and replace
Rob Sargent <[email protected]> Wed, 11 Sep 2019 14:27:48 -0600
| Newsgroups | gmane.comp.db.postgresql.sql |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_F8C1CDD0-FB15-48E5-9757-B6B0AC52800C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 11, 2019, at 2:24 PM, Campbell, Lance <[email protected]> = wrote: >=20 > PostgreSQL 10.x > =20 > I don=E2=80=99t know the best way to do this. I need to do a find and = replace in text fields. The value I need to find and replace may occur = more than once in each field per record.=20 > =20 > The value I am trying to match on: > Starts with a single { . > Ends with a single } . > In between these brackets can be the characters 0-9, a-z, A-Z, hyphens = and underscores. But no spaces. These characters could be in any = order. > The replacement value on a match is the same as what was found except = for double {{ at the beginning and double }} at the end. Same values = between the brackets as what was matched on. > =20 > Example: > {ab_1D3-4} becomes {{ab_1D3-4}} > =20 > Thanks for helping me with this. > =20 > Lance Campbell > University of Illinois Are there curly braces which don=E2=80=99t start/end such strings? If = not it might be easier to just double them up? --Apple-Mail=_F8C1CDD0-FB15-48E5-9757-B6B0AC52800C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><br = class=3D""><div><br class=3D""><blockquote type=3D"cite" class=3D""><div = class=3D"">On Sep 11, 2019, at 2:24 PM, Campbell, Lance <<a = href=3D"mailto:[email protected]" class=3D"">[email protected]</a>> = wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><div = class=3D"WordSection1" style=3D"page: WordSection1; caret-color: rgb(0, = 0, 0); font-family: CourierNewPSMT; font-size: 14px; font-style: normal; = font-variant-caps: normal; font-weight: normal; letter-spacing: normal; = text-align: start; text-indent: 0px; text-transform: none; white-space: = normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; = text-decoration: none;"><div style=3D"margin: 0in 0in 0.0001pt; = font-size: 12pt; font-family: Calibri, sans-serif;" class=3D""><span = style=3D"font-size: 11pt;" class=3D"">PostgreSQL 10.x<o:p = class=3D""></o:p></span></div><div style=3D"margin: 0in 0in 0.0001pt; = font-size: 12pt; font-family: Calibri, sans-serif;" class=3D""><span = style=3D"font-size: 11pt;" class=3D""><o:p = class=3D""> </o:p></span></div><div style=3D"margin: 0in 0in = 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" = class=3D""><span style=3D"font-size: 11pt;" class=3D"">I don=E2=80=99t = know the best way to do this. I need to do a find and replace in = text fields. The value I need to find and replace may occur more = than once in each field per record. <o:p = class=3D""></o:p></span></div><div style=3D"margin: 0in 0in 0.0001pt; = font-size: 12pt; font-family: Calibri, sans-serif;" class=3D""><span = style=3D"font-size: 11pt;" class=3D""><o:p = class=3D""> </o:p></span></div><div style=3D"margin: 0in 0in = 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" = class=3D""><span style=3D"font-size: 11pt;" class=3D"">The value I am = trying to match on:<o:p class=3D""></o:p></span></div><div = style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: = Calibri, sans-serif;" class=3D""><span style=3D"font-size: 11pt;" = class=3D"">Starts with a single { .<o:p class=3D""></o:p></span></div><div= style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: = Calibri, sans-serif;" class=3D""><span style=3D"font-size: 11pt;" = class=3D"">Ends with a single } .<o:p class=3D""></o:p></span></div><div = style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: = Calibri, sans-serif;" class=3D""><span style=3D"font-size: 11pt;" = class=3D"">In between these brackets can be the characters 0-9, a-z, = A-Z, hyphens and underscores. But no spaces. These = characters could be in any order.<o:p class=3D""></o:p></span></div><div = style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: = Calibri, sans-serif;" class=3D""><span style=3D"font-size: 11pt;" = class=3D""><o:p class=3D""></o:p></span></div><div style=3D"margin: 0in = 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" = class=3D""><span style=3D"font-size: 11pt;" class=3D"">The replacement = value on a match is the same as what was found except for double {{ at = the beginning and double }} at the end. Same values between the = brackets as what was matched on.<o:p class=3D""></o:p></span></div><div = style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: = Calibri, sans-serif;" class=3D""><span style=3D"font-size: 11pt;" = class=3D""><o:p class=3D""> </o:p></span></div><div style=3D"margin: = 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" = class=3D""><span style=3D"font-size: 11pt;" class=3D"">Example:<o:p = class=3D""></o:p></span></div><div style=3D"margin: 0in 0in 0.0001pt; = font-size: 12pt; font-family: Calibri, sans-serif;" class=3D""><span = style=3D"font-size: 11pt;" class=3D"">{ab_1D3-4} becomes = {{ab_1D3-4}}<o:p class=3D""></o:p></span></div><div style=3D"margin: 0in = 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" = class=3D""><span style=3D"font-size: 11pt;" class=3D""><o:p = class=3D""> </o:p></span></div><div style=3D"margin: 0in 0in = 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" = class=3D""><span style=3D"font-size: 11pt;" class=3D"">Thanks for = helping me with this.<o:p class=3D""></o:p></span></div><div = style=3D"margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: = Calibri, sans-serif;" class=3D""><span style=3D"font-size: 11pt;" = class=3D""><o:p class=3D""> </o:p></span></div><div style=3D"margin: = 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" = class=3D""><span style=3D"font-size: 11pt;" class=3D"">Lance = Campbell<o:p class=3D""></o:p></span></div><div style=3D"margin: 0in 0in = 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" = class=3D""><span style=3D"font-size: 11pt;" class=3D"">University of = Illinois</span></div></div></div></blockquote><br = class=3D""></div><div>Are there curly braces which don=E2=80=99t = start/end such strings? If not it might be easier to just double = them up?</div><div><br class=3D""></div><br class=3D""></body></html>= --Apple-Mail=_F8C1CDD0-FB15-48E5-9757-B6B0AC52800C--