I am using microsoft dynamics navision 2009 and I see sometimes this sign: '-'
what means '-' in microsoft dynamics navision 2009?
For example this:
IF FORMAT("Outbound Whse. Handling Time") <> '' THEN BEGIN
LocTxtHandlTime := '-' + FORMAT("Outbound Whse. Handling Time");
END ELSE BEGIN
LocTxtHandlTime := '';
END;
Thank you
The magic sign '-' is a string - in quotes. For example '' is an empty string and 'Apple' is a string Apple. In programming the quotes are necessary. Read some intro book.
Related
I am kinda new to AHK, I've written some scripts. But with my latest script, I'm kind of stuck with REGEX in AHK.
I want to make the report of a structure of texts I make.
To do this I've set up a system:
sentences ending on a '.', are the important sentences with "-". (variable 'Vimportant') BUT WITHOUT the words mentioned for 'Vanecdotes2' or 'Vdelete2' cfr. 4
sentences ending on a '.*', are the anecdotes (variable 'Vanecdotes1') where I've put a star manualy after the point.
sentences ending on a '.!', are irrelevant sentences and need to be deleted (variable 'Vdelete1') were I've put a star manually after the point.
an extra option I want to implement are words to detect in a sentence so that the sentence will be automatically added to the variable 'Vanecdotes2' or 'Vdelete2'
An random example would be this (I already have put ! and * after the sentence (why is not important) and of which "acquisition" is an example op Vanecdotes2 of my point 4 above):
Last procedure on 19/8/2019.
Normal structure x1.!
Normal structure x2.!
Abberant structure x3, needs follow-up within 2 months.
Structure x4 is lower in activity, but still above p25.
Abberant structure x4, needs follow-up within 6 weeks.
Normal structure x5.
Good aqcuisition of x6.
So the output of the Regex in the variables should be
Last procedure on 19/8/2019.
Normal structure x1.! --> regex '.!' --> Vdelete1
Normal structure x2.! --> regex '.!' --> Vdelete1
Abberant structure x3, needs follow-up within 2 months. --> Regex '.' = Vimportant
Structure x4 is lower in activity, but still above p25.* --> regex '.*' = Vanecdote1
Abberant structure x4, needs follow-up within 6 weeks. --> Regex '.' = Vimportant
Normal structure x5.! --> regex '.!' --> Vdelete1
Good aqcuisition of x6. --> Regex 'sentence with the word acquisition' = Vanecdote2
And the output should be:
'- Last procedure on 19/8/2019.
- Abberant structure x3, needs follow-up within 2 months.
- Abberant structure x4, needs follow-up within 6 weeks.
. Structure x4 is lower inactivity, but still above p25.
. Good aqcuisition of x6.
But I have been having a lot of trouble with the regex, especialy with the selection of sentences ending on a * or !. But also with the exclusion criteria, they just don't want to do it.
Because AHT doesn't have a real good tester, I first tested it in another regex tester and I was planning to 'translate' it later on to AHK code.. but it just doesn't work. (so I know in the script below I'm using AHK language with nonAHK regex, but I've just put the to together for illustration)
This is what i have now:
Send ^c
clipwait, 1000
Temp := Clipboard
Regexmatch(Temp, "^.*[.]\n(?!^.*\(Anecdoteword1|Anecdoteword2|deletewordX|deletewordY)\b.*$)", Vimportant)
Regexmatch(Temp, "^.*[.][*]\n")", Vanecdotes1)
Regexmatch(Temp, "^.*[.][!]\n")", Vdelete1)
Regexmatch(Temp, "^.*\b(Anecdoteword1|Anecdoteword2)\b.*$")", Vanecdotes2)
Regexmatch(Temp, "^.*\b(deletewordX|deletewordY)\b.*$")", Vdelete2)
Vanecdotes_tot := Vanecdotes1 . Vanecdotes2
Vdelete_tot := Vdelete1 . Vdelete2
Vanecdotes_ster := "* " . StrReplace(Vanecdotes_tot, "`r`n", "`r`n* ")
Vimportant_stripe := "- " . StrReplace(Vimportant, "`r`n", "`r`n- ")
Vresult := Vimportant_stripe . "`n`n" . Vanecdotes_ster
For "translation to AHK" I tried to make ^.*\*'n from the working (non ahk) regex ^.*[.][*]\n.
There isn't really such a thing as AHK regex. AHK pretty much uses PCRE, apart from the options.
So don't try to turn a linefeed \n into an AHK linefeed `n.
And there seem to be some syntax errors in your regexes. Not quite sure what those extra ") in there are supposed to be. Also, instead of using [.][*], you're supposed to use \.\*. The \ is required with those specific characters to escape their normal functionality (any character and match between zero and unlimited).
[] is to match any character in that group, like if you wanted to match either . or * you'd do [.*].
And seems like you got the idea of using capture groups, but just in case, here's a minimal example about them:
RegexMatch("TestTest1233334Test", "(\d+)", capture)
MsgBox, % capture
And lastly, about your approach to the problem, I'd recommend looping through the input line by line. It'll be much better/easier. Use e.g LoopParse.
Minimal example for it as well:
inp := "
(
this is
a multiline
textblock
we're going
to loop
through it
line by line
)"
Loop, Parse, inp, `n, `r
MsgBox, % "Line " A_Index ":`n" A_LoopField
Hope this was of help.
This i were i al up till now, nothing works (i will try the suggested loop when Regex is working): ^m::
BlockInput, On
MouseGetPos, , ,TempID, control
WinActivate, ahk_id %TempID%
if WinActive("Pt.")
Send ^c
clipwait, 1000
Temp := Clipboard
Regexmatch(Temp, "(^(?:..\n)((?! PAX|PAC|Normaal|Geen).)$)", Vimportant)
Vimportant := Vimportant.1
Regexmatch(Temp, "(^..*\n)", Vanecdotes1_ster)
Regexmatch(Temp, "(^..!\n)" , Vdelete1_uitroep)
Regexmatch(Temp, "(^.\b(PAX|PAC)\b.$)", Vanecdotes2)
Regexmatch(Temp, "(^.\b(Normaal|Geen)\b.$)", Vdelete2)
Vanecdotes1 := StrReplace(Vanecdotes1_ster, ".", ".")
Vdelete1 := StrReplace(Vdelete1_uitroep, ".!", ".")
Vanecdotes_tot := Vanecdotes1 . Vanecdotes2
Vdelete_tot := Vdelete1 . Vdelete2
Vanecdotes_ster := " " . StrReplace(Vanecdotes_tot, "rn", "rn* ")
Vimportant_stripe := "- " . StrReplace(Vimportant, "rn", "rn- ")
Vresult := Vimportant_stripe . "nn" . Vanecdotes_ster
Clipboard := Vresult
Send ^v
return
I have some non-regression test code in Delphi that calls an external diff tool. Then my code loads the diff results and should remove acceptable differences, such as dates in the compared results. I'm trying to do this with a multiline TRegEx.Replace , but no match is found ...
https://regex101.com/r/QBZuws/2 shows the pattern I came up with and a sample test diff file. I need to delete the matching "pararaphs" of 3 lines
Here is my code :
function FilterDiff(AText:string):string;
var
LStr:string;
Regex: TRegEx;
begin
// AText:=StringReplace(AText,#13+#10,'\n',[rfReplaceAll]); // doesn't help ...
LStr := '\d\d.\d\d.20\d\d \d\d:\d\d:\d\d'; // regex for date and time
LStr := '##.*##\n-'+LStr+'\n\+'+LStr; // regex for paragraphs to remove
Regex := TRegEx.Create(LStr, [roMultiLine]);
Result := Regex.Replace(AText,'');
end;
procedure TReportTest.NonRegression;
var
LDiff : TStringList;
// others removed for clarity
begin
// removed section code that call an external tool and produces diff.txt file
LDiff := TStringList.Create;
LDiff.LoadFromFile('diff.txt');
Status(FilterDiff(LDiff.Text)); // show the diffs in DUnit GUI for now
LDiff.Free;
end;
Besides, while tracing TRegEx.Replace down to
System.RegularExpressionsAPI.pcre_exec($4D72A50,nil,'--- '#$D#$A'+++ '#$D#$A'## -86 +86 ##'#$D#$A'-16.11.2017 15:00:36'#$D#$A'+15.11.2017 10:47:58'#$D#$A'## -400 +400 ##'#$D#$A'-16.11.2017 15:00:36'#$D#$A'+15.11.2017 10:47:58'#$D#$A,132,0,1024,$7D56800,300)
System.RegularExpressionsCore.TPerlRegEx.Match
System.RegularExpressionsCore.TPerlRegEx.ReplaceAll
System.RegularExpressions.TRegEx.Replace(???,???)
TestReportAuto.FilterDiff('--- '#$D#$A'+++ '#$D#$A'## -86 +86 ##'#$D#$A'-16.11.2017 15:00:36'#$D#$A'+15.11.2017 10:47:58'#$D#$A'## -400 +400 ##'#$D#$A'-16.11.2017 15:00:36'#$D#$A'+15.11.2017 10:47:58'#$D#$A)
I was surprised to see quotes before and after each newline #$D#$A in the debugger, but they don't look "real" ... or are they ?
As you seem to have issues with different kinds of line breaks, I would recommend to adjust your Regex to use \R instead of \n which matches Windows style linebreaks (CR + LF) as well as Unix style linebreaks (LF).
Well, I just noticed the \n in regex matches only LF, not CR+LF, so I added
AText:=StringReplace(AText,#13+#10,#10,[rfReplaceAll]); // \n matches only LF !
at the beginning of my function and it's much better now...
Sometimes writing down a problem helps ...
I am using delphi 10.1.
I have an unexpected result doing the following
procedure TForm1.FormCreate(Sender: TObject);
var
Match: TMatch;
Regex: TRegex;
Perl: TPerlRegEx;
const
s1 = 'Réaitaei: test123';
s2 = 'Réàààaitaei: test123';
s3 = 'Réàààààààààaitaei: test123';
pattern = '(.*): ';
begin
Regex := TRegex.Create(pattern);
Match := Regex.Match(s1);
Assert(Match.Success);
Memo1.Lines.Add(Match.Groups[1].Value);
Match := Regex.Match(s2);
Assert(Match.Success);
Memo1.Lines.Add(Match.Groups[1].Value);
Match := Regex.Match(s3);
Assert(Match.Success);
Memo1.Lines.Add(Match.Groups[1].Value);
Perl := TPerlRegEx.Create;
Perl.RegEx := pattern;
Perl.Compile;
Perl.Subject := s1;
Assert(Perl.Match);
Memo1.Lines.Add(Perl.Groups[1]);
Perl.Subject := s2;
Assert(Perl.Match);
Memo1.Lines.Add(Perl.Groups[1]);
Perl.Subject := s3;
Assert(Perl.Match);
Memo1.Lines.Add(Perl.Groups[1]);
end;
i get :
Réaitaei Réàààaitaei: t Réàààààààààaitaei: test
Réaitaei Réàààaitaei Réàààààààààaitaei
So TPerlRegex works but not TRegex when doc says that TRegex is just a wrapper to TPerlRegex.
Am I missing sth or it s a bug ?
I found a post from Marco Cantu saying that since delphi xe7, delphi uses pcre 8.35 so I am not expecting any problem from using unicode.
Looks like RSP-17697 solves this issue in Tokyo 10.2.1. When you run a compare on the relevant units you can see that TBytes was changed to Unicode String. I've checked my re-used RegEx and its not affected but for anyone not sure and using Berlin or lower use the class method to assure all works: TRegex.Match('Réàààààààààaitaei: test123', '(.*): ').Groups[1].Value = 'Réàààààààààaitaei'
That would be one heck of a bug to hunt down
I've reviewed this question and I'm wondering my output seems to be a little skewed.
From my understanding the REGEXP_REPLACE method, takes a string that you want to replace content with, followed by a pattern to match, then anything that does not match that pattern is replaced with the substitution param.
I've written the following function to extract distance from a text field, in which a spatial query will be performed on the result.
CREATE OR REPLACE FUNCTION extract_distance
(
p_search_string VARCHAR2
)
RETURN VARCHAR2
IS
l_distance VARCHAR2(25);
BEGIN
SELECT REGEXP_REPLACE(UPPER(p_search_string), '(([0-9]{0,4}) ?MILES)', '')
INTO l_distance FROM SYS.DUAL;
RETURN l_distance;
END extract_distance;
When I run this in a block to test:
DECLARE
l_output VARCHAR2(25);
BEGIN
l_output := extract_distance('Stores selling COD4 in 400 Miles');
DBMS_OUTPUT.PUT_LINE(l_output);
END;
I'd expect the output 400 miles but in-fact I get Stores selling COD4 in. Where have I gone wrong?
"REGEXP_REPLACE extends the functionality of the REPLACE function by letting you search a string for a regular expression pattern. By default, the function returns source_char with every occurrence of the regular expression pattern replaced with replace_string." from Oracle docu
You could use, e.g.,
SELECT REGEXP_REPLACE('Stores selling COD4 in 400 Miles', '^.*?(\d+ ?MILES).*$', '\1', 1, 0, 'i') FROM DUAL;
or alternatively
SELECT REGEXP_SUBSTR('Stores selling COD4 in 400 Miles', '(\d+ ?MILES)', 1, 1, 'i') FROM DUAL;
You'll want to use, regexp_substr which returns a substring that matches the regular expression.
REGEX_SUBSTR
I am trying to extract text in the form:
1.The tree has only green apples.
a. the person is boy.
b. the person is a liar.
2.The car drove very fast.
a. it was driven by a mad man.
b. it was by a little girl.
I want the "1.The tree has only green apples." parts of all the paragraphs.
My results list should contain "1.The tree has only green apples.","
2.The car drove very fast"... I have written a regex expression "\d{1,2}.\s(.+?\n\n|.+?$)" and tested on various engines and it works. I can't see why this will not work in delphi xe 5.
Here is the code that I use it from:
procedure TForm1.btSearch;
var
regex: TRegEx;
i, j: integer;
mygrps: TGroupCollection;
begin
regex:= TRegEx.Create(edit1.text);
mycoll:= regex.Matches(memo1.text);
if mycoll.Count>0 then
begin
label2.caption:= 'Count: ' + IntToStr(mycoll.Count);
memo2.Lines.Add('First Collection: ');
for i := 0 to mycoll.Count-1 do
begin
memo2.Lines.Add('Match #' + IntToStr(i) + ': ' + mycoll.Item[i].Value);
memo2.Lines.Add('Group: ' + IntToStr(i));
mygrps:= mycoll.Item[i].Groups;
for j := 0 to mygrps.Count-1 do
begin
memo2.Lines.Add('Value: ' + mygrps.Item[j].Value);
end;
end;
end;
end;
This has nothing to do with Delphi at all. Your regular expression is appears to be incorrect. It doesn't match your supplied text in any engine I can find.
Given the following text (from your sample, properly formatted):
1. The tree has only green apples.
a. the person is boy.
b. the person is a liar.
2. The car drove very fast
a. it was driven by a mad man.
b. it was by a little girl.
The following regular expression matches the two lines you've indicated as your desired result (tested in JGSoft, .NET, PCRE, Java, Perl, JavaScript, XMLSchema, XPath, and Perl engines):
\d{1,2}\.\s.*
When you tested with "various engines", you didn't take into account that various applications and programming languages handle line breaks differently. In Delphi, TMemo.Text returns a string with CRLF line breaks. To match one such line break in Delphi you need the regex \r\n.