I have a long document with links in the usual format i.e.:
Link Text
I need to replace all links like this with the following:
[Link Text](http://www.somelink.com/tosomewhere)
Or, ideally:
[Link Text](http://www.somelink.com/tosomewhere "Link Text")
Is this possible somehow with Dreamweaver regular expression?
Just figured it out.
Go to Find and Replace. Enter the following:
Search:
(.*)
Replace:
[$2]($1)
Check "use regular expression box".
Click "Replace all".
Related
Whenever I type something in the sublime text "find" bar,it is enclosed by "\b" and the text is not found even when it is there.
Below pic will explain it clearly.
You have enabled the whole word option in the search dialog (see the button with the quote-symbol), that's what enables the word boundary regular expression.
What's the simplest way to do a find and replace for a given input string from filename,
Example:
filename is
abc.txt
Find inside text file:
Name = "xyz",
Nametitle = "xyz",
and replace to:
Name = "abc",
Nametitle = "abc",
What the easiest way to achieve my goal?
Can i use notepad++?
I see this is your first question on stackoverflow. Perhaps you are new to programming? But your question isn't really a programming question. But that is ok.
Sure, use notepad++: open the options for search and replace.
Add in the word you want to find, and the word you want to replace it with.
Do this for each word you want to replace.
Be sure to check the option to make it search for only the entire word: Otherwise your xyz could also match xyzFoo. And you might not want to replace it with abcFoo.
Also look for the option to search with case sensitivity (based on your preferences really).
Notepad++ is a fine editor if you are on windows. On a mac there are a myriad other options.
I have a regex expression that I use regularly to find specific lines in my codebase.
Let's say the expression is
\s*<search keyword> = myClass(.*)
with <search keyword> being the part of the regex that changes depending of the search.
How can I make entering such a search as fast as possible in ST3?
I tried using snippets that at first sight seem to fill my need as they enable to set the location where the text editing will be resumed, so I could just type <snippet alias><TAB><search keyword> in Find: field to trigger the search.
Alas no, snippets are disabled in search fields (only accessible in main text window).
You can use snippets in search bar, for example:
<snippet>
<content><![CDATA[
\s*$1 = myClass(.*)
]]></content>
<tabTrigger>search</tabTrigger>
<description>Search snippet</description>
</snippet>
BUT you can only expand them with CTRL+Space. Tab key for snippet expansion does not work in search field.
Btw: This works for me in Sublime Text 2. But it should work in Sublime Text 3 too
Doing some String manipulation and I want to ask if the below is possible in Notepad++:
I have a string with Years:
10-Jan-13
22-Feb-14
10-Jan-13
10-Mar-13
I want
10-JAN-13
22-FEB-14
10-JAN-13
10-MAR-13
(There's more data on each line there but I am just showing a simplified example).
I know I can OR search with | character so find, JAN|FEB|MAR... but how do I replace according to what's found.
(Just trying to save some time)
Thanks.
Not sure if it's a plugin or built-in, but you can use the TextFX Characters plugin, to select the text, and then in the textfx characters dropdown, click UPPER CASE.
Update
Looks like it is a plugin:
TextFX menu is missing in Notepad++
Multiple Files
I found this site which gives a way to convert text to uppercase with regular expressions: http://vim.wikia.com/wiki/Changing_case_with_regular_expressions
So, what you can do is bring up the find in files dialog (CTRL+SHIFT+F), change search mode to Regular Expression, and then use something like this:
Find: (\d{2}-\w{3}-\d{2})
Replace with: \U\1
Directory: Whichever directory your files are in (and only the files you want changed).
\U is an uppercase flag, and the brackets in the Find regex correspond with the \1 backreference, which will basically replace it with itself (but uppercase).
Let's say I have the following:
['cart', 'horse']
Is there a quick way to swap the two so I have the following:
['horse', 'cart']
I'm referring to the actual text and not reordering an array programmatically. For example, I usually do something like this:
Highlight and cut " 'horse'"
Delete the trailing comma
Paste " 'horse'" before "'cart'"
Delete the leading space
Add ", " after "'horse'"
I find myself needing to do this type of thing frequently, so I'm wondering if TextMate has some type of built-in functionality/bundle for accomplishing this.
Thanks.
When I have to do something like this, I will use regular expressions in the Search & Replace dialog.
Search for: '(.*)', '(.*)'
Replace with: '$2', '$1'
And make sure that the "Regular Expression" box is ticked. There may be a bundle that can help out with this, but I often find it easier to write a quick regex to reorder/rearrange.