I am currently using AutoHotKey, and I'm using lots of sub-functions. And so, in Notepad++, I would like to define a style for lines ending with ":".
An example of this situation would be :
FillGroup:
Gosub, GetID
Send, sometext {Down} {Enter}
Return
(FillGroup would be in blue, for example)
Even though I'm kind of a newbie to it, I tried some Regex in the Open delimiter section(I tried .+: and .+:$), but without conclusive results.
IMO, and until proven wrong, there is no (clean) way to do this since UDL 2.0 doesn't support regex.
You may brute force it by setting all the possible values of the opening within (( )) and separated by a space and the end with something like :((EOL))
Related
I'm using Atom to format some text data for analysis (I know there are probably better ways of doing it than this so I'm all ears) but it doesn't seem to be recognizing my regular expression.
The text is POS tagged tokens with sentences being delineated with newlines, formatted as such:
good\tJJ\n
workout\tNN\n
.\t.\n
''\t''\n
\n
Perhaps\tRB\n
the\tDT\n
I was able to replace all of the tabs (\t) with a front slash (/) no problem, but I'm now trying to turn all newlines that DON'T delineate sentences with just a space. I tried \S\n and it "wasn't found". I also tried to highlight all delineating newlines with ^\n$ but there were only two matches and only at the end of the document.
Am I doing this wrong? My only usage of regex is with Python, so maybe there's just a different way to do it in Atom.
EDIT: I'm just giving up and gonna use Python to process it. Nothing suggested work. The search function seemed to just be bugging out in general (e.g. one search would not work but then if I closed the search function and reopened it, the same search would work) because it's a long file (700,000+ lines) despite it not being a large file, data-wise (6,235 KB). If anyone can recommend a large file text editor, though, it would be appreciated.
I have a code setup like this:
'olderVehicleHdr' : '#cft("We can still find you the right tires. Tell us what you drive.")#'
,'weCanStillHelpYou' : '#cft("We can still help.")#'
,'name' : '#cft("Name")#'
I need to switch the ' ' over to " " but there is A LOT of these in this file. and I'd rather not do each one individually so I thought I would try a regex setup. However I don't want the single quotes around the cft and ending # sign to be selected, since they need to be single quotes in order for the double quotes to work.
For example: I want to take 'name' : '#cft("Name")#' and turn the single quotes around name and make them double quotes like so: "name" : '#cft("Name")#'
This regex will be used on sublime to search for the appropriate characters and replace them. So my question is, can you make a regex that only selects the single quotes at the begining of the line and replace them? Without disturbing the second set of single quotes?
I've tried some of the lookbehind methods but they don't seem to work either. Any help would be greatly appreciated. thanks!
if sublimetext3 regex engine is based on PCRE use this pattern
'#cft[^']*'(*SKIP)(*F)|'
Demo
After a bit of tinkering, I have actually found a regex combo which seems to do the trick:
(?<![a-z]|\(|\\)'(?=[a-z]|[A-Z]|[0-1])|(?<=[a-z]|[0-9])'(?!\)) It's a tad bit sloppy but I only need it very rarely, and it works to me needs for right now. Thank you for your time to try and help me solve this!
I'm trying to clean up an long CSV file using SublimeText instead of Excel.
I've created a RegExp which use some greedy expression like
^.somehting.com.au.$
The search pattern works fine, but when it comes to the replacing everything with a blank string, Sublime return an error in the bottom bar I can barely read as it immediately disappears without anything happening.
I do suspect it's an error, and I have read something "too generic" rule or something.
Any help?
Ok, Sublime Text use a particular syntax for Reg Expr that slightly differs from the one used in coding.
In my specific circumstance, to find a domain in a string using a greedy expression including the carriage return (useful to clean a huge amount of rubbish in an SEO backlinks spreadsheet) I ended up using the following.
.*://leaderlive.co.uk/.*\n
Dots doesn't require escaping ... no need to add the end of string ^$ ... it simply works and I didn't spend time investigating the reasons.
I would like to remove hundreds on onmouseover events from my code. the evt all pass different variables and I want to be able to use dreamwaever to find and replace all the strings with nothing.
Here is an example
onmouseover="parent.mv_mapTipOver(evt,'Wilson');"
onmouseover="parent.mv_mapTipOver(evt,'Harris');"
onmouseover="parent.mv_mapTipOver(evt,'Walker');"
I want to run a search that will identify all of these and replace/remove them.
I have tried seemingly infinite permutations of things like:
onmouseover="parent.mv_mapTipOver(evt,'[^']');"
or
onmouseover="parent.mv_mapTipOver(evt,'[^']);"
or
onmouseover="parent.mv_mapTipOver(evt,[^']);"
or
onmouseover="parent.mv_mapTipOver(evt,'[^']+');"
And many more. I cannot find the regular expression that will work.
Any/all help would be appreciated.
Thanks a ton!
"." and "(" have special meaning in regular expressions, so you need to escape them:
onmouseover="parent\.mv_mapTipOver\(evt,'[^']+'\);"
I'm not sure if this is correct dreamweaver regex syntax, but this stuff is standard enough.
Try this one:
onmouseover="parent\.mv_mapTipOver\(evt,'.+?'\);"
And see it in action here.
When using reg expressions you have to be very careful about how you handle white space. For example the following piece of code will not get caught by most of the reg expressions mentioned so far because of the space after the comma and equals sign, despite the fact that it is most likely valid syntax in the language you are using.
onmouseover= "parent.mv_mapTipOver(evt, 'Walker');"
In order to create regexp that ignore white space you must insert /s* everywhere in the regexp that white space might occur.
The following regexp should work even if there is additional white space in your code.
onmouseover\s*=\s*"parent\.mv_mapTipOver\(\s*evt\s*,\s*'[A-Za-z]+'\s*\);"
I'm using Notepad++ to do some text replacement in a 5453-row language file. The format of the file's rows is:
variable.name = Variable Value Over Here, that''s for sure, Really
Double apostrophe is intentional.
I need to convert the value to sentence case, except for the words "Here" and "Really" which are proper and should remain capitalized. As you can see, the case within the value is typically mixed to begin with.
I've worked on this for a little while. All I've got so far is:
(. )([A-Z])(.+)
which seems to at least select the proper strings. The replacement piece is where I'm struggling.
Find: (. )([A-Z])(.+)
Replace: \1\U\2\L\3
In Notepad++ 6.0 or better (which comes with built-in PCRE support).
Regex replacement cannot execute function (like capitalization) on matches. You'd have to script that, e.g. in PHP or JavaScript.
Update: See Jonas' answer.
I built myself a Web page called Text Utilities to do that sort of things:
paste your text
go in "Find, regexp & replace" (or press Ctrl+Shift+F)
enter your regex (mine would be ^(.*?\=\s*\w)(.*)$)
check the "^$ match line limits" option
choose "Apply JS function to matches"
add arguments (first is the match, then sub patterns), here s, start, rest
change the return statement to return start + rest.toLowerCase();
The final function in the text area looks like this:
return function (s, start, rest) {
return start + rest.toLowerCase();
};
Maybe add some code to capitalize some words like "Really" and "Here".
In Notepad++ you can use a plugin called PythonScript to do the job. If you install the plugin, create a new script like so:
Then you can use the following script, replacing the regex and function variables as you see fit:
import re
#change these
regex = r"[a-z]+sym"
function = str.upper
def perLine(line, num, total):
for match in re.finditer(regex, line):
if match:
s, e = match.start(), match.end()
line = line[:s] + function(line[s:e]) + line[e:]
editor.replaceWholeLine(num, line)
editor.forEachLine(perLine)
This particular example works by finding all the matches in a particular line, then applying the function each each match. If you need multiline support, the Python Script "Conext-Help" explains all the functions offered including pymlsearch/pymlreplace functions defined under the 'editor' object.
When you're ready to run your script, go to the file you want it to run on first, then go to "Scripts >" in the Python Script menu and run yours.
Note: while you will probably be able to use notepad++'s undo functionality if you mess up, it might be a good idea to put the text in another file first to verify it works.
P.S. You can 'find' and 'mark' every occurrence of a regular expression using notepad++'s built-in find dialog, and if you could select them all you could use TextFX's "Characters->UPPER CASE" functionality for this particular problem, but I'm not sure how to go from marked or found text to selected text. But, I thought I would post this in case anyone does...
Edit: In Notepad++ 6.0 or higher, you can use "PCRE (Perl Compatible Regular Expression) Search/Replace" (source: http://sourceforge.net/apps/mediawiki/notepad-plus/?title=Regular_Expressions) So this could have been solved using a regex like (. )([A-z])(.+) with a replacement argument like \1\U\2\3.
The questioner had a very specific case in mind.
As a general "change to sentence case" in notepad++
the first regexp suggestion did not work properly for me.
while not perfect, here is a tweaked version which
was a big improvement on the original for my purposes :
find: ([\.\r\n][ ]*)([A-Za-z\r])([^\.^\r^\n]+)
replace: \1\U\2\L\3
You still have a problem with lower case nouns, names, dates, countries etc. but a good spellchecker can help with that.