Calculating with AutoWikiBrowser - regex

I'm using regular expression in AutoWikiBrowser to replace the input of several values with just one value, such as this:
|value1=4
|value2=5
|value3=6
To this:
|value={{#expr:4+5+6}}
While the correct result does show on the page, it does not look good in the code itself, so I'm trying to find a way to make it the result only (in this case value=15) but so far no luck. Can someone help me with out showing how to make this possible?
P.S. I tried the search function but didn't find a similar question.

MediaWiki parser allows the templates can be subst'ed, ie replaced by their rendering. That's also true for parser functions call.
You can subst a template prefixing the template call by subst:.
|value={{subst:#expr:4+5+6}}
Reference: Substitution on MediaWiki manual
Example: diff (the expression used is in the edit summary, the result in the diff)

Related

Find specified position's value on a function decleration

I try to find method(function) declerations on which 6th argument is true. Actually I think I can return ,just using regex, wished group without using an extra programming language's feature, unfortunately no option exits as such.
sdfsdfs(123,234,werer,23324,234324,true,dwfwefwer,sdfdsdff);
sdfsdfs(123,234,true,23324,234324,true,dwfwefwer);
sdfsdfs(123,234,234234,23324,234324,r23423,dwfwefwer);
sdfsdfs(123,234,234234,23324,234324,false,dwfwefwer);
(123,234,werer,23324,234324,true,dwfwefwer,sdfdsdff)
erterterterter(123,234,werer,23324,234324,true,dwfwefwer,sdfdsdff);
What I have tried is here. (\b\w+(?=\s*[,()]))
You can check the following regex.
(?i)\w*\([^,]+,[^,]+,[^,]+,[^,]+,[^,]+,true\b,[^\)]+\)
I have done here https://regex101.com/r/BEJNp4/1/

Regex-Match while ignoring a char from Searchword

I am using an Engineering Program which lets me Code formulas in order to filter out specific lines in a database. I am trying to look for a certain line in the database which contains e.g. "concrete" as a property.
In the Code I can use regular expressions.
The regex I was using so far looked like this:
".*(concrete).*";
so if the line in the database contains concrete, I will get the wanted result.
Now the Problem is: i would like to switch the word concrete with a variable, so that it Looks like this:
".*(#VARIABLE1).*";
(the Syntax with the # works in the program btw.)
the Problem is: if i set the variable as concrete, the program automatically switches it for 'concrete' . Obviously, the word concrete cant be found anymore, since the searchterm now contains the two ' Symbols in the beginning and i the end.
Is there a way to ignore those two characters using the Right regex?
what I want it to do is the following:
If a line in the database contains "25cm concrete in Grey"
I should get a match from the regex.
with the searchterm ".*(concrete).*"; it works, with the variable ".*(#VARIABLE1).*"; it doesnt.
EDIT:
the whole "Formula" in the program Looks like that:
if(Match(QTO(Typ:="Attribut{FloorsLayer_02_MaterialName}");".*(#V_QUALITY).*" ;"regex") ;QTO(Typ:="Attribut{Fläche}");0)
I want the if-condition to be true, when the match inside is true.
the whole QTO function is just the programs Syntax to use a certain Attribute into the match-function, the middle part is my Problem. I really don't know the programming language or anything,I'm new to this. hope it helps!
Thats more of a hack than a real solution and i'm not sure if it even works:
if you use the regex
.*(#VARIABLE1)?).*
and the string ?concrete(
this will result in a regex looking like this:
.*('?concrete(')?).*
which makes the additional characters optional.
This uses the following assumtption:
the string (#VARIABLE1) gets replaced by the ('<content of VARIABLE1>')

How to I make gerrit query that spans across few specific projects?

I tried for few hours to find the right syntax for making a regex query that returns reviews from 2-3 different projects but I failed and decided to crowdsource the task ;)
The search is documented at https://review.openstack.org/Documentation/user-search.html and mentions possible use of REGEX,... but it just didn't work.
Task: return all CRs from openstack-infra/gerritlib and openstack-infra/git-review projects from https://review.openstack.org
Doing it for one project works well project:openstack-infra/gerritlib
Ideally I would like to look for somethign like ^openstack-infra\/(gerritlib|git-review), or at least this is the standard regex syntax.
Still, I found impossible to use parentheses so far, every time I used them it stopped it from returning any results.
1) You don't need to escape the "/" character.
2) You need to use double quotes to make the parentheses work.
So the following search should work for you:
project:"^openstack-infra/(gerritlib|git-review)"

Visual studio find all Assert.IsTrue that have no message

I'm trying to find using visual studio regular expressions (https://msdn.microsoft.com/en-us/library/2k3te2cs.aspx) all calls to Assert.IsTrue that only pass the Boolean argument, for example Assert.IsTrue(parameter) would be one and Assert.IsTrue(parameter, "message") wouldn'
t.
For simple things, Assert.IsTrue\(([a-zA-Z ]+)\) does the trick, this works for the example provided above but not for things when there are evaluations done for example Assert.IsTrue(2 > 3). For this I tried using Assert.IsTrue\((.+[^,])\) so it matches everything that doesn't have "," but this only filters when the , is at the end, I'm not sure how to filter commas inside.
Finally, what I really want to do (which I'm not sure if it's possible with regular expressions alone) is to find Assert.IsTrue that have only one parameter but this parameter could be a method call, so it could have commas or not, something like Assert.IsTrue(isTrue(p1,p2))
I don't know why you want the solution to be programmatically, but if it's ok for you to have a Visual Studio based solution, you could just look for an example of Assert.IsTrue(parameter);, right click the method and select "Find all references`.
Remove the .+ from your second example and add a * also you should escape the period directly after Assert.
Assert\.IsTrue\(([^,])*\)
As for your expanded expression, something like this might work.
Assert\.IsTrue\(([a-zA-Z\.])*\(.*\)\)
This should let you find what you're looking for.

Emacs org-mode link formatting

I use org-mode in emacs to created structured documents but one of the features I'm really interested in and would like to use for other areas are the way links are formatted. Say for example I want to create a link to another location take google for example I could simply write
[[http://www.google.com][To Google]] and as soon as I complete the second square bracket it will change to look like To Google but the underlying structure remains in tact, if I remove the second bracket it simply expands again.
I have downloaded the source code but I cant seem to find where this has been implemented. If anyone knows how it has been achieved I would be very grateful for an explanation. I would imagine It could be replicated with regular expressions but im rather clueless.
Thanks
You can digg from here: C-h f org-activate-bracket-links RET.
C-h f org-toggle-link-display RET and C-h f org-link-display-format RET are also good starting points.