RegExReplace can't process (unicode comma)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Jem
Posts: 7
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: 868
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: 7
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: 868
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: 868
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: 868
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: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

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]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

swagfag
Posts: 6222
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: 7
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: 9001
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: 7
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: 426
Joined: 27 Oct 2017, 14:30
Contact:

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: 868
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: 9001
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 (v1)”

Who is online

Users browsing this forum: Anput, JoeWinograd, Nerafius and 88 guests