I'm trying to apply a very simple regex to a Rich Text Box in Umbraco 7.
The regex I'm trying to apply is [^£\$].
I've tried some simple ones, [a-zA-Z], etc, but nothing seems to take effect.
Switching the property to as textString, and the regexes work immediately.
What am I doing wrong?
Thanks,
john
The point is that the rich text editor in Umbraco has various settings and it can show different types of content.
Regular expressions are used to find matches inside text data only.
Thus, setting the content type to textString for regex-based search to work is logical.
The fact that the regex box is not grayed out when a non-supporting mode is selected is most probably a minor bug.
Related
I'm trying to make a snippet that is triggered by a regular expression. Is it even possible in Sublime Text 3?
I've tried this but it doesn't trigger. I've already checked that sublime replaces it correctly with the Find and Replace option.
<snippet>
<content><![CDATA[$1_$2
]]></content>
<tabTrigger>([a-zA-z])(\d)</tabTrigger>
<description></description>
<scope>text.tex.latex</scope>
</snippet>
I want my snippet to be triggered by pressing tab after any word that matches a character followed by a digit and replace it with the character, a _, and the digit.
Examples
a1 turns into a_1
X0 turns into X_0
The trigger text for a sublime-snippet file has to be literal text in order to trigger; Sublime won't match it based on a regular expression. To do something like that you need a plugin command that is bound to the tab key (for example) that triggers a command that examines the text to the left of the cursor to see if it matches the regex and then expand it based on that.
I'm not aware of a general purpose package that does something like this (although Emmet does this for expanding HTML tags, it's not generic and is known to interfere with regular tab completion) but there may be one listed on package control.
This forum post on the Sublime forum includes a sample plugin that does something very similar to this that may be useful as a starting point for something like this, though. Based on your examples above, it should do what you want as long as you swap the scope in the example for the one from your snippet so that it triggeres in LaTeX files instead of Markdown. You may want to rename the command as well in that case.
[Edit] If you're not sure how to use plugin in Sublime Text, this video covers how to do it.
My guess is that, maybe this expression,
(?i)(?<=<tabTrigger>[a-z])(?=\d<\/tabTrigger>)
replaced with _ might be something that you might have in mind, for instance.
If you wish to explore/simplify/modify the expression, it's been
explained on the top right panel of
regex101.com. If you'd like, you
can also watch in this
link, how it would match
against some sample inputs.
I was trying to update one of my old Xcode 7 answers that described how to do regular expression matching. However, I can't get the Textual Matching Style to work now. In Xcode 7, I could do something like this:
which gave me pattern matching like this:
But in Xcode 8 the green bubbles don't show up. I get a (\w+) but that doesn't match anything in the Textual style anymore. And when I am in The Regular Expression Matching Style, I don't have all the nice Insert Pattern hints anymore.
What am I doing wrong?
Note: I'm not asking for the regex answer. I'm asking how to get the Insert Pattern hints to work.
You switched your find options Matching Style from Text to Regular Expression. To revert this, simply click on the magnifying glass next to the search field, select Edit find options... and set the Matching Style back to text.
Just now I was working on a fancy search and replace regular expression.
It looked good so I tested it on one entry then went to the editing area and the search and replace box went away.
I reopened the search and replace box to continue, but the selected text in the edit window replaced my search expression.
Control Z in the search box did not go back to my regex but undid the last change in the editing area.
I can't seem to find a way to get back to previous regexes in the find box. Is there any way? Googling turned up nothing.
Currently, Adobe Brackets doesn't maintain any kind of history of search and replace expressions. The feature is still missing.
I've been searching a lot in the web and in here but I can't find a solution to this.
I have to make two replacements in all registry paths saved in a text file as follows:
replace all asterisc with: [#42]
replace all single backslashes with two.
I already have two expressions that do this right:
1st case:
Find: (\*) - Replace: \[#42\]
2nd case:
Find: ([^\\])(\\)([^\\]) - Replace: $1$2\\$3
Now, all I want is to join them together into just one expression so that I can do run this in one time only.
I'm using Notepad++ 6.5.1 in Windows 7 (64 bits).
Example line in which I want this to work (I include backslashes but i don't know if they will appear right in the html):
HKLM\SOFTWARE\Classes\*\shellex\ContextMenuHandlers\
I already tried separating it with a pipe, like I do in Jscript (WSH), but it doesn't work here. I also tried a lot of other things but none worked.
Any help?
Thanks!
Edit: I have put all the backslashes right, but the page html seem to be "eating" some of them!
Edit2: Someone reedited my text to include an accent that doesn't remove the backslashes, so the expressions went wrong again. But I got it and fixed it. ;-)
Sorry, but this was my first post here. :)
As everyone else already mentioned this is not possible.
But, you can achieve what you want in Notepad++ by using a Macro.
Go to "Macro" > "Start Recording" menu, apply those two search and replace regular expressions, press "Stop Recording", then "Save Current Recorded Macro", there give it a name, assign a shortcut, and you are done. You now can reuse the same replacements whenever you want with one shortcut.
Since your replacement strings are totally different and use data that come not from any capture (i.e. [#42]), you can't.
Keep in mind that replacement strings are only masks, and can not contain any conditional content.
I'm working with an enterprise CMS and in order to properly create our weekly-updated dropdown menu without republishing our entire site, I have an XML document being created which has a various number of useful XML elements. However, when pulling in a link with the CMS, the generated XML also outputs the link's contents (the entire HTML for the page). Needless to say, with roughly 50 items, the XML file is too big for use on the web (as it stands I think it's over 600KB). The element is <page-content>filler here</page-content>.
What I'm trying to do is use TextWrangler to find and replace all <page-content> tags as well as their containing content.
I've tried a few different regex's, but I can't seem to match the closing tag, so it will just trail on.
Here's what I've tried:
(<page-content>)(.*?)
The above will match up until the next starting <page-content> tag, which is not what I want.
(<page-content>)(.*?)(<\/page-content>)
(<page-content>)(.*?)(<\/page\-content>)
The above finds no matches, even though the below will find the 7 matches it should.
(<content>)(.*?)(<\/content>)
I don't know if there's a special way to deal with hyphens (I'm inexperienced in regular expressions), but if anyone could help me out, it would be greatly appreciated.
Thanks!
EDIT: Before you tell me that Regex isn't meant to parse HTML, I know that, but there seems to be no other way for me to easily find and replace this. There are too many occurences to manually delete it and save the file again every week.
It seems the problem is that your . is not matching newlines that exist between your open and close tags.
An easy solution for this would be to add the s flag in order for your . to match over newlines. TextWrangler appears to support inline modifiers (?s). You could do it like this:
(<page-content>)(?s)(.*?)(<\/page-content>)
More information on modifiers here.