Skip to main content
Participating Frequently
March 7, 2022
Question

Another REGEX question, Replace portion

  • March 7, 2022
  • 1 reply
  • 542 views

I have created a RegEx that I use for replacing dates in specific locations. I need to replace the date in two locations in the file, one in the metadata, another at the foot of the page. The search works perfectly as intended.

((<meta name="dcterms.modified" title="W3CDTF" content=")|(<time property="dateModified">))[\s]*[\d\-]{10}[\s]*("|</time>)


However I'm unsure how to use the replace portion which would be

$12022-03-07$4


Entered as above, the result is literally $12022-03-07[proper value of $4].
How do I get it to insert value $1 and 2022 with no break?
Once again, it's probably basic, but it's driving me nuts.

 

    This topic has been closed for replies.

    1 reply

    Community Expert
    March 7, 2022

    I'm not sure I understand your problem. At first reading, it seems that there is no need for a regular expression to make your changes. A simple advanced search and replace should be enough.
    Could you please specify the current HTML content (within the META tag and TIME tag) and just indicate in complement the replacement strings?

    Participating Frequently
    March 7, 2022

    This is one of a number of saved queries that I'm modifying to adapt to my content. There are other searches that need the same answer.
    How do I insert a variable followed immediately by a number, for example
    Search: (some content)1997-12-12(some other content)

    Replace: $12022-03-07$2
    $1=some content
    $2=some other content
    Result as above: $12022-03-07some other content
    Desired result : some content2022-03-07some other content
    With no spaces between some content and 2022-03-07

    Hopefully this is clearer.