Jump to content

Replacing changing pattern in a string with a new pattern


icydash

Recommended Posts

Hey guys.  So I'm trying to write a script that replaces footnote citations in one format with footnote citations in another format.

 

For example, the text will read:  "Then he went down the street.[1] That is where the police found him [2].  They immediately arrested him at the house. [3]"

 

And I would like the script to find the [ #] strings and replace them with {#} ... so that the string reads:

"Then he went down the street.{1} That is where the police found him {2}.  They immediately arrested him at the house. {3}"

 

Note that there will be double, and even tripple, digit footnotes, so the script has to be able to recognize [##] or [###] and replace the brackets with {} accordingly.

 

I'm not really sure how to do this, since the "pattern" is constantly changing depending on the number between the brackets.  Ideas?

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.