Highlighted

Reg Ex wildcard help please

Community Beginner ,
Jun 10, 2019

Copy link to clipboard

Copied

I have many, many strings of html code in Dreamweaver, scattered all through the document, such as:

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn4" name="_ednref4">[4]</a>

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn5" name="_ednref5">[5]</a>

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn6" name="_ednref6">[6]</a>

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn7" name="_ednref7">[7]</a>


My first step is simply to find all occurrences of lines that match that pattern.   I'm trying to use wildcards to construct this search:

Find each occurrence of a string that BEGINS with <a href="file:///C:/Users   and ENDS with   ]</a>

So if it finds:
<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn4" name="_ednref4">[4]</a> 

Then I can click FIND NEXT and it will then find

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn5" name="_ednref5">[5]</a>

etc etc

I'm stuck with my syntax, and would appreciate any advice.

Alternatively, you could use:

<a href="file:[^"]+" name="[^"]+">(\[[\w\d]+\])</a>

V/r,

^ _ ^

DW_RegEx_fileColonSlashSlashSlash.png

Views

178

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Reg Ex wildcard help please

Community Beginner ,
Jun 10, 2019

Copy link to clipboard

Copied

I have many, many strings of html code in Dreamweaver, scattered all through the document, such as:

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn4" name="_ednref4">[4]</a>

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn5" name="_ednref5">[5]</a>

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn6" name="_ednref6">[6]</a>

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn7" name="_ednref7">[7]</a>


My first step is simply to find all occurrences of lines that match that pattern.   I'm trying to use wildcards to construct this search:

Find each occurrence of a string that BEGINS with <a href="file:///C:/Users   and ENDS with   ]</a>

So if it finds:
<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn4" name="_ednref4">[4]</a> 

Then I can click FIND NEXT and it will then find

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn5" name="_ednref5">[5]</a>

etc etc

I'm stuck with my syntax, and would appreciate any advice.

Alternatively, you could use:

<a href="file:[^"]+" name="[^"]+">(\[[\w\d]+\])</a>

V/r,

^ _ ^

DW_RegEx_fileColonSlashSlashSlash.png

Views

179

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 10, 2019 0
Adobe Community Professional ,
Jun 10, 2019

Copy link to clipboard

Copied

You understand that any and all references to file:///C:/Users/.... are pointing to files on your local hard drive that nobody can access except you.  Start by defining your local site folder.   Site > New Site >  enter the site folder name.  For example, C:\MyTestSite.

CC-localsite.jpg

File > Save All.

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 10, 2019 1
Community Beginner ,
Jun 10, 2019

Copy link to clipboard

Copied

Yes, thank you.    That's why I want to find those strings so I can replace each one with the correct one.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 10, 2019 0
Adobe Community Professional ,
Jun 10, 2019

Copy link to clipboard

Copied

To perform a search of your current document or your entire current local site, use Ctrl + Shift + F (Find).  See screenshot.  Hit Find All.   Your Results Panel will show a list.  Double click each item in the list to open the code.

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 10, 2019 1
Community Beginner ,
Jun 13, 2019

Copy link to clipboard

Copied

Thank you, but my question has nothing to do with my C drive.   I certainly know how CTRL-F works. I'm asking for Reg Ex help.

I have a large html file with many strings in it like the ones I posted above, scattered through.   I need help with  Reg Ex search for this query:

Find every instance of a phrase beginning with <a href="file:///C:/Users/User/AppData/Article-final-draftdocx# 

and

ending with ]</a>

Such a Reg Ex search will find all the lines I need to find, no matter what number is included in those lines.

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn6" name="_ednref6">[6]</a>

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn22 name="_ednref22">[22]</a>

<a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn437 name="_ednref437">[437]</a>

etc etc etc

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 13, 2019 0
Adobe Community Professional ,
Jun 13, 2019

Copy link to clipboard

Copied

This is simple stuff. You don't need Reg Ex to find all stings containing file:///C:/ (whatever...) in DW.  Do what I suggested and you'll find them all in your results panel.  Try it and see for yourself.

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 13, 2019 0
LEGEND ,
Jun 13, 2019

Copy link to clipboard

Copied

As Nancy has explained, it would be much easier to do a TAG search than a REGEX search.  Once they are all found, you can go to each one by one and make the edits.

HTH,

^ _ ^

UPDATE:  And that's not easy for me to say, coz I _love_ RegEx. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 13, 2019 1
Community Beginner ,
Jun 14, 2019

Copy link to clipboard

Copied

Thank you , Nancy.  I misunderstood what you were advising, and it worked great!

The only thing about finding that string and then manually editing one by one is that there are so many !

On a string like this, I need to FIND this pattern <a href="file:///C:/Users/User/AppData/Article-final-draftdocx#_edn6" name="_ednref6">[6]</a>

And REPLACE it with replace it with just [6].   (only keep the red characters in the line above).

That's why I was thinking of RegEx originally.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
LEGEND ,
Jun 14, 2019

Copy link to clipboard

Copied

Ah!  Details are important.  I did not see that in your original post.  So, let me understand.  You are attempting to do a mass find/replace where you are completely removing the anchor tag and leaving only the text between opening and closing anchor tags?

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
Community Beginner ,
Jun 14, 2019

Copy link to clipboard

Copied

LOL, yes the details woulda been nice.  I realize my original question was worded unclearly.

You have understood it correctly, and you worded it much better than me!    Yes, the goal is to remove the anchor tags but retain the text.

(the text, in every case, will be bracket-number-bracket)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
LEGEND ,
Jun 14, 2019

Copy link to clipboard

Copied

Okay.. I have to swap out my KVM, it's been acting up for weeks.  But when I get that done, I can show you how to do it with RegEx using backreference.

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
LEGEND ,
Jun 14, 2019

Copy link to clipboard

Copied

Okay, back up and running, hopefully this KVM won't flip out on me. 

So, the first thing you need to do is to make sure your search is limited to the current document, unless you do need to do this to the whole site.  Next is to make sure you've got the Use Regex option checked.  Third, make sure you're getting ONLY the ones you intend to target by just doing a search, not a replace.    CYA!

In the search field, use:

<\s*a\shref="[^"]"\sname="[^"]">(\[:alphanum:+\])<[^>]+>

If it isn't getting all the intended anchors, let me know and I will revise it.

Once you are absolutely sure that this search will get you only the intended anchors, do a replace with:

$1

HTH,

^ _ ^

UPDATE:  For those not that familiar with RegEx, the search string explained:

LT followed by zero or more whitespaces followed by 'a' followed by a space followed by href=" followed by anything that is NOT a " followed by a " followed by a space followed by name=" followed by anything that is NOT a " followed by a " followed by a GT.

The parenthesis are the backreference.  This surrounds what you need to keep.  So keep:

Left bracket (escaped) followed by one or more letters/numbers followed by a right bracket (escaped).

Now remove the closing anchor tag:

LT followed by anything that isn't a GT followed by a GT.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
Community Beginner ,
Jun 14, 2019

Copy link to clipboard

Copied

Thank you, but no.   The FIND string was yielding zero finds.   I do indeed have the RegEx box checked, and confined the search to the current doc only.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
LEGEND ,
Jun 14, 2019

Copy link to clipboard

Copied

Okay.. let me open DW and tweak it a bit.. I'll post it as soon as I have it.

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
LEGEND ,
Jun 14, 2019

Copy link to clipboard

Copied

Got it..

<a href="file:[^"]+" name="[^"]+">(\[\d{1,}\])</a>

Put that in the search.  Works in my Dw.

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
Community Beginner ,
Jun 14, 2019

Copy link to clipboard

Copied

Perfect perfect perfect.   Thank you.

<a href="file:[^"]+" name="[^"]+">(\[\d{1,}\])</a>    That did the trick!

Could you please explain your syntax if you have a minute?  It finds everything that begins with <a href=file and then I'm confused how you built it after that.   Thanks so much!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
LEGEND ,
Jun 14, 2019

Copy link to clipboard

Copied

Sure thing!

<a href="file:

This is pretty straightforward.  Look for an anchor tag that has an href that begins with "file:".

[^"]+

Followed by anything that isn't a quote ("); the + means one or more.

" name="

Followed by a quote, a space, the attribute name with corresponding = and a quote.

[^"]+

Same as before; one or more of anything that isn't a quote.

">

Followed by a quote and the closing > of the opening anchor tag.

(\[\d{1,}\])

The parenthesis are the backreference.  You are saving the data that is between them.  Since there is only one, you refer to it with "$1".  It is looking for the bracket-number-bracket that is between the opening and closing anchor tags.  \d is 'digit', the {1,} is the same as +; one or more.

</a>

The closing anchor tag.  Honestly this should be more like <\s*/a\s*> in case any closing tags have whitespace in them (* is zero or more.)  But this will work as long as ALL closing tags are properly formatted.

HTH,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 2
Community Beginner ,
Jun 14, 2019

Copy link to clipboard

Copied

Thank you again.    That breakdown of your syntax is invaluable!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
LEGEND ,
Jun 14, 2019

Copy link to clipboard

Copied

Glad I could help.  And, thank you for marking my answer as correct.  I do appreciate it, and I'm sure someone else might find it useful, too.

Have a great weekend.

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
LEGEND ,
Jun 14, 2019

Copy link to clipboard

Copied

Alternatively, you could use:

<a href="file:[^"]+" name="[^"]+">(\[[\w\d]+\])</a>

V/r,

^ _ ^

DW_RegEx_fileColonSlashSlashSlash.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0
LEGEND ,
Jun 14, 2019

Copy link to clipboard

Copied

I'll be at my desk working late for about another two hours, if you need any more assistance.

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2019 0