Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
in fact it does not answer my question, I try to reformulate,
could you please tell me the exact HTML you are looking for and the final replacement HTML... for example
I look for
<meta name="dcterms.modified" title="W3CDTF" content="foo-date"/>
and I would like to replace it by
<meta name="dcterms.modified" title="W3CDTF" content="2022-10-03"/>
because as I told you in my previous comment, probably, it could be done without using REGEX
Copy link to clipboard
Copied
Well it could be
<meta name="dc.terms.modified" title="W3CDTF" content="1999-12-27">
or
<meta name="dcterms.modified" title="W3CDTF" content="2017-12-30">
or
<time property="dateModified">2022-01-01</time>
or
<p>Date modified: 2012-04-01</p>
or
<p>Date de modification : 2009-09-30</p>
What I want to achieve is to place a number directly after the variable $x without having to introduce a space.
Copy link to clipboard
Copied
So there is no way to insert an escape character in a replacement string after a back reference (using \ as an example)?
$1\2022
Copy link to clipboard
Copied
So the following should cover finding all the date strings above
(<meta[^>]*modified"[^>]*|<p>Date de modification[\s]*:[\s]*|<p>Date modified:[\s]*|<time property="dateModified">)[\d\-]{10}
but I need the escape character in the replacement string. Maybe this is not possible in DW.
$1[escape]yyyy-mm-dd
Copy link to clipboard
Copied
@Up in the Hills, thank you for the HTML fragments that help me to contextualize your queries.
I'm in location until the end of the week so I don't have DW at hand right now. Well, I just checked your expressions and they seem quite correct.
As you mention, and as I suspect, if they don't work in DW, it must be a bug.
In that case, for heavy and/or voluminous processing, I often use Notepad++ which is a real Swiss knife in this matter. However, note that Notepad++ does not accept named substitutions (in a usual way).
So use $1 or $+ instead of the substitution's naming used in the previous illustration.
Copy link to clipboard
Copied
Thanks for the help @L e n a . I was trying to keep it to Dreamweaver as that is the tool we use the most, and I have built up a library of search and replace RegEx queries that I use on a regular basis.
I have one that achieves what I want already, but I have been trying to streamline it so that I only have to enter the date once manually in the substitution.
I do use Notepad++ (and UltraEdit) on occasion already for more complex searches, especially when I need to filter pages... Different topic.
If you ever do find a way to escape the substitution like this in DW, that would be great. 🙂
$n\nnn