I need to replace some html file names in my html file with anchor tags, such that:
abc.html
file.html
becomes:
abc.html
file.html
I have though of the following regex in find: [a-z-0-9]+\.html and it seems to work, but I don't know what to add in replace. I have tried some answers from here , but they did not work. Can you please help?
You need to use capturing groups, that then you can refer back to in the replace box..
Capture groups are created adding parenthesis to find: ([a-z-0-9]+\.html)
Then replace would be: $1
$1 means the first capture group.
Related
In a string like
Hallo, this is <code>`code`</code> and this `is code again`.
To analyse it, parse it with regex?
In this example the user just typed the far right ` at the very last. The first "code" has obviously already been surrounded by HTML.
I need a regex to get the next code indicated part.
There always be one series, that is valid markdown AND not already surrounded by the corresponding HTML tags.
How to get this specific series (regardless if it's *, **, ___, ` or whatever)?
So what you want is a regex that only matches the markdown that isn't surrounded by HTML tags right ?
You can use something like this :
/(?:[^<>]|^)(`[^<>].*?`)/
This will only match the text placed inside `` that aren't directly placed next to a < or > character. This way, no matter what the HTML tag is inside the <...>, the `code` won't match.
See this Regex101.com
If you want to match every emphasized string that is not tagged with "code" you can use
(?<!<code>)`[\w ]+`
You can test it on regex101.com
I have a text document with raw links (not wrapped) and I would like to wrap them in HTML anchor tags.
Link example:
http://example.com/images/my-image.jpg
Desired output:
http://example.com/images/my-image.jpg
I can FIND the links in Notepad++ using the following RegEx:
[-a-zA-Z0-9#:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9#:%_\+.~#?&//=]*)?(\?([-a-zA-Z0-9#:%_\+.~#?&//=]+)|)
However, the REPLACE string I'm trying is not working for some reason:
\1
How can I do this with notepad++?
You need to replace with the backreference to the whole match:
$&
Or
$0
Here, the $0 and $& "insert" the text that is matched by the whole regular expression, not just by some capturing groups.
I'd like to use Regex to match HTML tag "head" and text inside them so I can delete them easily. I'm using a find and replace tool that is utilizing regex syntax and it really works great in replacing multiple files at once.
I tried doing a lot of syntax but I always fail.
http://regex101.com/r/aZ6pN5/2
Anyone can help please?
Replace .* in your regex with [\S\s]*?, so that it would match line breaks also. You can't use s DOTALL modifier in JavaScript.
<head.*?>([\s\S]*?)<\/head>
[\s\S]*? This would do an non-greedy match of zero or more space or non-space characters.
DEMO
OR
To replace the contents of head tag.
(<head\b[^<>]*>)[\s\S]*?(<\/head>)
Replacement string:
$1stringyouwant$2
DEMO
I want to replace <whatever>Some Title</whatever> with <something>Some Title</something> using the Find and Replace tool inside of Dreamweaver. How do I perform?
Not a Dreamweaver user, but this simple approach works in my editor (Emacs):
Replace:
<whatever>\(.*\)</whatever>
With:
<something>\1</something>
This is a pretty straightforward approach but it may fall short of your needs. Do some or all of your <whatever> element pairs occupy more than one line of text? Or do you have more than one <whatever> pair on a single line?
i guess what you want is to change all your <whatever> tag with an <something> tag whitout changing your text, right?
If it is so, you want to use find and replace with regular expression. Find (in source code) <whatever>(.*)</whatever> and replace it with <something>$1</something>. The $1 is used as a variable for anything fits the (.*) part DW finds for each instance.
For example, you you want to comment all instances of an
document.NAMEOFANYFORMONTHEPAGE.WHATEVERNAME.focus();
in a JavaScript file, you would use find:
document\.(.*)\.focus\(\);
and replace it with:
// document.$1.focus();
Don't forget to escape special characters and, please, try a few instances before using Replace All
I have a ton of text replacements to make and I would like to try and do this all at once instead of manually. I'm trying to replace <a class='stuff morestuff' href='#'>Some Text</a> with Some Text; essentially stripping off the surrounding anchor tag.
I've been messing around with a search/replace in Visual Studio using regex, but am not really getting anywhere. My latest attempt:
Find what:
\<a class='stuff morestuff' href='#'\>(.+)\<\/a\>
Replace with:
$1
If what I want to do is even feasible, how can I correct my regex to accomplish this?
This regex will match your anchors if the class and href are always the same:
Find: \<a[^\>]class='stuff morestuff' href='\#'[^\>]*\>(.*)\</a\>
Replace: $1
This regex will replace all the anchors with the inner text:
Find: \<a[^\>]*\>(.*)\</a\>
Replace: $1
I'm assuming from your post you plan to use this in Visual Studio's Find/Replace and not in code.
Find:\\<a class='.*?' href='#'>(.*?)\\</a\\>
Replace: $1