Dreamweaver regexp positive look behind error - regex

I'm getting a syntax error and invalid quantifier error in dreamweaver when I try to use a regexp in the source code.
The purpose is to find spaces in front of numbers on table cells and delete them.
(?<=>)\s+(?=\d)
this expression works on notepad++ but not in dreamweaver.
Can this be a Dreamweaver bug or the syntax is wrong?
Of course I can make a text search looking for >\s and replace by > but then I cant catch more spaces than the ones specified in the search string
thanks in advance
PS: Would be nice also to have a multisearch option in the dreamweaver search screen, to run multiple search and replace in one operation, like code clean up. An extension maybe?

I don't use DW but, since I have read several posts about lookarounds problems with DW, I assume that DW doesn't support these regex features.
You can use capturing groups instead (if DW supports it!):
search : (>)\s+(\d)
replace: $1$2
or
replace: \1\2

To append to the previous answer, when formulating a replace statement in DreamWeaver, use the format of $1 rather than ^1 for the variables.
I receive a similar "invalid quantifier" response in DreamWeaver CC 2015.1 when using a negative lookbehind:
(?<!somephrase)

Related

Regex find a specific character zero or one or multiple time in a string

I'm upgrading a Symfony app with VSCode and I have numerous occurences of this kind of string :
#Template("Area:Local:delete.html.twig")
or
#Template("Group:add.html.twig")
In this case, I want to replace all the : with / to have :
#Template("Area/Local/delete.html.twig")
I can't think of doing it manually, so I was looking for a regular expression for a search/replace in the editor.
I've been toying with this fearsome beast without luck (i'm really dumb in regexp) :
#Template\("([:]*)"
#Template\("(.*?)"
#Template\("[a-zA-Z.-]{0,}[:]")
Still, I think there should be a "simple" regexp for this kind of standard replacement.
Anyone has any clue ? Thank you for any hint
You can use this regex with a capture group: (#Template.*):.
And replace with this $1/.
But you'll have to use replace all until there's no : left, that won't take long.
Just explaining a lit bit more, everything between the parenthesis is a capture group that we can reference later in replace field, if we had (tem)(pla)te, $1 would be tem and $2 would be pla
Regex!
You can use this regex #Template\("(.[^\(\:]*)?(?:\:)(.[^\(\:]*)?(?:\:)?(.[^\(\:]*)?"\) and replacement would simply be #Template\("$1/$2/$3
You can test it out at https://regex101.com/r/VfZHFa/2
Explanation: The linked site will give a better explanation than I can write here, and has test cases you can use.

VS Code, find/replace access find results in the replace field

I have phone numbers on my file and I would like to surround each of them with braces, so if I have this:
"+49-1111"
"+49-2222"
I would like to run a replace operation and to get this:
["+49-1111"]
["+49-2222"]
Is that possible with the current vs code find/replace action?
If it is a dup sorry but I could find any explanation anywhere.
Thanks
This is more relevant to regular expression.
Find ("\+\d{2}-\d{4}"), replace the occurrences with [$1]
Be sure to turn the "Use Regular Expression" switch on.

Regular Expression Searching Matching One Word but Not Another

<ReportExport ID="export1" runat="server" AlertNoTests="false" PDFPageOrientation="Portrait"
HideExcel="true" OnPDFClicked="CreatePDF" AllowPDFOptions="true" HideBulkPDFOptions="false"
HideOrientation="true" HidePaperSize="true" MaxReportsAtOnce="250" HideTextExport="true" />
I'm trying to use Visual Studio's find feature using regular expressions to find ReportExport in my entire solution where the HideTextExport property is not being set. This is only ever defined in the markup once on a given page.
Any ideas on how I would find where ReportExport exists... but HideTextExport does not exist in the text?
Thanks in advance!
This works for me:
\<ReportExport(:Wh+~(HideTextExport):w=:q)+:Wh*/\>
:Wh+ matches the whitespace preceding the attribute name and :w matches the name, but only after ~(HideTextExport) confirms that the name is not "HideTextExport". :q matches the attribute's value (assuming values are always quoted). < and > have to be escaped or VS Find will treat them as word boundaries.
This is effectively the same as the .NET regex,
<ReportExport(?:\s+(?!HideTextExport)[A-Za-z]+="[^"]+")+\s*/>
First off one should install the Productivity Power tools to Visual Studio (via Tools->Extension Manager) and use .net regex instead of the antiquated regex provided out of the box for the Visual Studio Find.
With that the user could use this regex pattern (if the productivity power tools has singleline turned on to handle the span of lines for the element):
(ReportExport.+?HideTextExport="false")
That will return all reportexports where its false and one could tweak the regex to change it to replace false to true.
But...if the HideTextExport is missing, this makes regex a poor choice to use to find this element because the uncertantity of the location of the attribute makes the .* or .+ too greedy and ends reporting false positives when trying to find a missing text in a match.
A generalized way of saying that is, regex finds patterns and that is its job, but it requires lexical analsys to find missing patterns where regex simply cannot.

Visual Studio Find and Replace with Regex

I want to replace C# attributes with VB.NET, which means, [Serializable] should become <Serializable>.
The pattern (\[)(.+)(\]) does find the results but I don't know how to replace the first and the last groups with the appropriate parenthesis.
I read this page, but I didn't understand how to use the curly braces for F&R, I tried to wrap the groups with it but it didn't work.
If you are using the Productivity Power Tools extension from Microsoft that support normal .NET regexes, what you would put in the textbox for the replacement given your regular expression above is:
<$2>
where $2 refers to the second capture group in your regex, i.e. the text between the brackets.
Note that this only works with the Quick Find from Productivity Power Tools though. The normal find/replace in Visual Studio use another syntax altogether.
Find what: \[{Serializable}\]
Replace with: <\1>

Regex not returning 2 groups

I'm having a bit of trouble with my regex and was wondering if anyone could please shed some light on what to do.
Basically, I have this Regex:
\[(link='\d+') (type='\w+')](.*|)\[/link]
For example, when I pass it the string:
[link='8' type='gig']Blur[/link] are playing [link='19' type='venue']Hyde Park[/link]"
It only returns a single match from the opening [link] tag to the last [/link] tag.
I'm just wondering if anyone could please help me with what to put in my (.*|) section to only select one [link][/link] section at a time.
Thanks!
You need to make the wildcard selection ungreedy with the "?" operator. I make it:
/\[(link='\d+')\s+(type='\w+')\](.*?)\[\/link\]/
of course this all falls down for any kind of nesting, in which case the language is no longer regular and regexs aren't suitable - find a parser
Regular Expressions Info a is a fantastic site. This page gives an example of dealing with html tags. There's also an Eclipse plugin that lets you develop expressions and see the matching in realtime.
You need to make the .* in the middle of your regex non-greedy. Look up the syntax and/or flag for non-greedy mode in your flavor of regular expressions.