Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2017-11-27 05:07:49

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,086
Website Mastodon

Editing a Mysql db

I have a dump of a MySQL database that i would like to change the occurrence of a string to another. The major issue is that there are 3 different forms of the span class. for example i want to change this span example:

 <span class=\"footnote\"> this part contains random and a variety of texts</span>

to this occurrence:

 <sup><span class=\"footnote\"> this part contains random and a variety of texts</span></sup>

i have 800 of such span entires.

any hints? i suspect i have to some fancy grep work beyound my skill set.


…. texted postive

Offline

#2 2017-11-27 06:46:44

jpdupont
Member
Registered: 2004-10-01
Posts: 752

Re: Editing a Mysql db

Simply replace <span class by <sup><span class and </span> by </span></sup> ???

Last edited by jpdupont (2017-11-27 06:57:46)

Offline

#3 2017-11-27 06:55:35

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,086
Website Mastodon

Re: Editing a Mysql db

hmmm. i have over 800 occurrences that i need to CHANGE! i cannot do a global replacement of </span> as that would change it places where it should not be changed,

So, find all occurrences of: <span class=\“footnote\”> this part contains random and a variety of texts</span>

change them all to :

<sup><span class=\“footnote\”> this part contains random and a variety of texts</span></sup>

I have 3 classes occurring: <class= footnote> and class =quotes> and <class=other> i need to change class of FOOTNOTE only

Last edited by bici (2017-11-27 07:05:25)


…. texted postive

Offline

#4 2017-11-27 07:04:40

jpdupont
Member
Registered: 2004-10-01
Posts: 752

Re: Editing a Mysql db

I usually work on the dump mysql in an ordinary editor (Sublime, …). Time to type your comment here, both search and replace would be finished, no ??? But I may not see all the problems in this case :))

Offline

#5 2017-11-27 07:08:20

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,086
Website Mastodon

Re: Editing a Mysql db

jpdupont wrote #308013:

I usually work on the dump mysql in an ordinary editor (Sublime, …). Time to type your comment here, both search and replace would be finished, no ??? But I may not see all the problems in this case :))

i thought of that as well. i can easily edit and replace <span class=\“footnote\”> to <sup><span class=\“footnote\”> BUT how do i change the trailing </span> on ONLY the class=footnote occurrences and not the other occurrences?


…. texted postive

Offline

#6 2017-11-27 07:53:40

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Re: Editing a Mysql db

First of all, set your editor’s search and replace to regex mode. Usually there’s an extra button or switch for that.

Then search for

(<span class=\\"footnote\\">.*</span>)

and replace with

<sup>$1</sup>

The logic is search for your string with .* meaning zero or more matches of a single character. A backslash is a special character for grep, so the double \\ means search for that character. The brackets mean the equivalent of “save this matched block for later” and the $1 is re-using it for the replacement string. I use Patterns to experiment with grep searches.

Check first that the editor is matching the find correctly and try out on individual instances that you can undo before doing the whole replace.


TXP Builders – finely-crafted code, design and txp

Offline

#7 2017-11-27 17:48:14

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,086
Website Mastodon

Re: Editing a Mysql db

thank-you


…. texted postive

Offline

Board footer

Powered by FluxBB