Processing Semicolon

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Processing Semicolon

Post by tiago »

Why I can't use regexreplace or trim on semicolon?
Power-hungry user!!!

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Processing Semicolon

Post by highend »

Examples where it doesn't work?
One of my scripts helped you out? Please donate via Paypal

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Processing Semicolon

Post by tiago »

Sure.

Code: Select all

   $tk = "(test);";
// step;
   $tk = regexreplace("$tk", "chr(59)", ""); //otherwise regexmatches will bitch...
   $tk = trim("$tk", eval("chr(59)")); //otherwise regexmatches will bitch...
   $tk = trim("$tk", "*;(+)."); //otherwise regexmatches will bitch...
   text "no semicolon here?<crlf>$tk";
Power-hungry user!!!

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Processing Semicolon

Post by highend »

No clue what you're talking about...

Code: Select all

    $tk = "(test);";
    $tk = regexreplace($tk, ";");
    text $tk;

    $tk = "(test);";
    $tk = trim($tk, ";");
    text $tk;
"*;(+)."
What's that, a regex pattern?
One of my scripts helped you out? Please donate via Paypal

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Processing Semicolon

Post by tiago »

So it seems I don't understand quoting too.

Removing quotes on "$tk" makes it work.
highend wrote:
"*;(+)."
What's that, a regex pattern?
No. Those characters, perhaps more, if present on input make regexmatches throw error messages for each time they happen on a loop. Anyway I'm considering asking a silent mode for cases like these.

Thanks very much for your assistance, highend! Soon I'll post the entire script on a new post per your instructions so you can check what improvements can be made, as you suggested on the thanks thread ("I bet that can be done faster xD").
Power-hungry user!!!

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Processing Semicolon

Post by tiago »

I really cant take it.

Now it's not working again:

Code: Select all

   $tk = "(te);";
 step;
   $tk = regexreplace($tk, "chr(59)", ""); //otherwise regexmatches will bitch...
   $tk = trim($tk, eval("chr(59)")); //otherwise regexmatches will bitch...
   $tk = trim("$tk", "*;(+)."); //otherwise regexmatches will bitch...
   text "no semicolon here?<crlf>$tk";
Got it.
If copied from forum, it works.
Will attach it in a few secs...
Power-hungry user!!!

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Processing Semicolon

Post by highend »

Ehm, removing of quotes around $tk has what to do with this case?
This is just unnecessary quoting, that's all.

Code: Select all

$tk = regexreplace("$tk", "chr(59)", "");
This is crap. You're quoting a scripting command which makes it a string, not a command.
make regexmatches throw error messages
These are special characters. They need to be escaped in a regex pattern. A semicolon isn't one of them^^
Soon I'll post the entire script on a new post per your instructions so you can check what improvements can be made, as you suggested on the thanks thread
Mine takes 1313 ms to produce the alphabetical sorted list "Abwurf.wav = 1<crlf>..."
One of my scripts helped you out? Please donate via Paypal

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Processing Semicolon

Post by tiago »

It's a trick problem. If you bother...

Go here:
http://www1.folha.uol.com.br/mercado/20 ... agem.shtml

Put the text in print preview, copy the whole page;

Paste the content on a notepad window;

Locate "(SP);" on it, copy it and use it as source for "$tk" variable at the posted script (any version).

-regexreplace and trim will not process it!
Power-hungry user!!!

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Processing Semicolon

Post by tiago »

highend wrote:Ehm, removing of quotes around $tk has what to do with this case?
This is just unnecessary quoting, that's all.
I agree.
highend wrote:Mine takes 1313 ms to produce the alphabetical sorted list "Abwurf.wav = 1<crlf>..."
How do you do the measurement???
Power-hungry user!!!

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Processing Semicolon

Post by highend »

Show screenshots of:
Notepad with the selected text that you want to copy
Your text editor after inserting the text
One of my scripts helped you out? Please donate via Paypal

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Processing Semicolon

Post by highend »

Code: Select all

    $start = now("msecs");

... code to execute ...

    $duration = now("msecs") - $start;
    text $duration . " msecs";

One of my scripts helped you out? Please donate via Paypal

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Processing Semicolon

Post by tiago »

xy ss1.png
xy ss1.png (20.18 KiB) Viewed 3478 times
highend wrote: Your text editor after inserting the text
What?
I insert it right into the Run Script dialogue. Once done coding, then I paste both code and processed text into plain text files.
Power-hungry user!!!

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Processing Semicolon

Post by bdeshi »

tiago wrote:

Code: Select all

   $tk = "(te);";
 step;
   $tk = regexreplace($tk, "chr(59)", ""); //otherwise regexmatches will bitch...
   $tk = trim($tk, eval("chr(59)")); //otherwise regexmatches will bitch...
   $tk = trim("$tk", "*;(+)."); //otherwise regexmatches will bitch...
   text "no semicolon here?<crlf>$tk";

Code: Select all

$tk = regexreplace($tk, "chr(59)", "");
What you're trying to do here is asking the script to match the string "chr(59)" in $tk. This could've worked if $tk = "I have chr(59) within me"; . You should not quote function calls when you want to use their return. Use them like this: $v = "prefix" . function() . "suffix";
Anyway, chr() is not needed at all. You can just do

Code: Select all

   $tk = regexreplace($tk, ";", "");
   $tk = trim($tk, ";");
This is the FIRST thing you should've tried, before all that eval(), chr() business. :maf:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Processing Semicolon

Post by tiago »

Hello, SammaySarkar!
Thanks for popping up.
SammaySarkar wrote:
tiago wrote:

Code: Select all

   $tk = "(te);";
 step;
   $tk = regexreplace($tk, "chr(59)", ""); //otherwise regexmatches will bitch...
   $tk = trim($tk, eval("chr(59)")); //otherwise regexmatches will bitch...
   $tk = trim("$tk", "*;(+)."); //otherwise regexmatches will bitch...
   text "no semicolon here?<crlf>$tk";

Code: Select all

$tk = regexreplace($tk, "chr(59)", "");
What you're trying to do here is asking the script to match the string "chr(59)" in $tk. This could've worked if $tk = "I have chr(59) within me"; . You should not quote function calls when you want to use their return. Use them like this: $v = "prefix" . function() . "suffix";
Anyway, chr() is not needed at all. You can just do

Code: Select all

   $tk = regexreplace($tk, ";", "");
   $tk = trim($tk, ";");
This is the FIRST thing you should've tried, before all that eval(), chr() business. :maf:
Not so fast, pal, not so fast!
I did started with simple'r versions. As they proved to be useless on the input described above I started experimenting.
Try to use the attached zipped .txt as source, thus avoiding the complicated steps I described, and perhaps you can see for yourself.
Attachments
Clipboard-20160516.zip
(7.94 KiB) Downloaded 104 times
Power-hungry user!!!

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Processing Semicolon

Post by bdeshi »

You said you want to extract the (SP); part and trim it, but since this is already a known static string, there doesn't seem much need for scripting.
How exactly do you want to process that attached text?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply