RegExReplace can't process (unicode comma)

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Jem
Posts: 4
Joined: 22 Jun 2020, 08:44

RegExReplace can't process (unicode comma)

22 Jun 2020, 08:54

Code: Select all

“宁肯我负天下人,不可天下人负我”……
Do this: Select above text, copy (Ctrl-C) and press ctrl-alt-shift-c, the above (unicode double-quote) didn't change to (unicode single-quote) even when there's no (unicode comma) in it. i.e. the RegEx can't process this somehow? Bug?

Code: Select all

^!+c::  ; Control+Alt+Shift+C hotkey.
  s := clipboard
  s := RegExReplace(s, "“([^,]+)”", "‘$1’") ; replaces (unicode double-quote) to (unicode single-quote)
  clipboard := s
  Send ^v
Return
Last edited by Jem on 22 Jun 2020, 20:19, edited 1 time in total.
toralf
Posts: 793
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 09:49

You may add (*UCP) at the start of the needle. That might help, not tested though.
ciao
toralf
User avatar
Jem
Posts: 4
Joined: 22 Jun 2020, 08:44

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 10:49

deleted
Last edited by Jem on 22 Jun 2020, 20:19, edited 1 time in total.
toralf
Posts: 793
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 12:04

Put it before the brace
ciao
toralf
toralf
Posts: 793
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 12:10

Code: Select all

s := RegExReplace(s, "(*UCP)“([^,]+)”", "‘$1’")
not tested
ciao
toralf
toralf
Posts: 793
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 12:13

Looking at your needle, I do not think it has something to do with Unicode. Your needle seems not to find the string in quotes, because the string contains a comma and space
ciao
toralf
User avatar
Delta Pythagorean
Posts: 575
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 13:48

Wouldn't it be better to use the escaped code of the quote?

- [AHK].......: 1.1.33.02 Unicode 64-bit
- [OS].........: Windows 10.0.19041
- [GITHUB]...: github.com/DeltaPyth
- [PAYPAL]....: paypal.me/DelPyth
- [DISCORD]..: Tophat Cat // Delta#8888

Remember to use [code]CODE[/code] for your multi-line scripts.
Stay safe, stay inside, and remember to wash your hands for 20 seconds!
swagfag
Posts: 4141
Joined: 11 Jan 2017, 17:59

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 15:39

look at the regex u wrote:
  • find me a substring that contains a pair of funny looking opening quotes
  • onemany chars that arent a funny looking comma
  • immediately followed by a pair of funny looking closing quotes
what do u think happens when the regex read head expects a set of funny looking closing quotes but is looking at a funny comma? exactly - it fails. this has nothing to do with unicode
string contains a comma and space
wrong
use the escaped code of the quote
u can, but ultimately it doesnt matter
User avatar
Jem
Posts: 4
Joined: 22 Jun 2020, 08:44

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 19:17

I realised this is my fault so I would like to delete this post, how do I do that?
gregster
Posts: 5837
Joined: 30 Sep 2013, 06:48

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 21:31

Please don't empty posts that have so many answers already. That doesn't help anyone, is bad for forum integrity and against forum rules.
No one will hold your question against you, but might help others.
Thank you.
User avatar
Jem
Posts: 4
Joined: 22 Jun 2020, 08:44

Re: RegExReplace can't process (unicode comma)

22 Jun 2020, 23:27

Thanks gregster for pointing this out, but I posted this when I was having a great headache; well now is getting slightly worse; so there are things I didn't 'see' at that time, and now after I realised it, this is a mistake on my part and nothing can be gained by anyone to see it in all honesty. So it is best not to pollute the forum, imho, and delete this post entirely.

You can find out why I say this by just looking at the codes of the 'recovered' 1st post.

Let me know if this post can be deleted after you've done the research. Cheers!
Jem
User avatar
Frosti
Posts: 379
Joined: 27 Oct 2017, 14:30
GitHub: Ixiko

Re: RegExReplace can't process (unicode comma)

23 Jun 2020, 04:45

I agree with gregster. I read this post and learned a new regex option (*UCP). Nice!
toralf
Posts: 793
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: RegExReplace can't process (unicode comma)

23 Jun 2020, 09:36

Yes, leave it. It is also now in the ask for help section.
Btw: I and and I assume most of all users have had these kind of posts. I had several of them, were I thought I was on the right track. Had long arguments with Chris to find out at the end that I was wrong or had made a mistake. So, don”t worry, you are in good company...
ciao
toralf
gregster
Posts: 5837
Joined: 30 Sep 2013, 06:48

Re: RegExReplace can't process (unicode comma)

23 Jun 2020, 10:22

Thanks guys, for showing support and encouragement for this new user!

@Jem: Please have a look at your PMs!

Return to “Ask For Help”

Who is online

Users browsing this forum: ark, LC99, Spawnova and 36 guests