A back-up RegEx please? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

A back-up RegEx please?

Post by PepeLapiu » 20 May 2022, 21:40

So here is the clipboard content:

Code: Select all

 Clipboard:="
Send exactly

0.00125994 BTC
To the address below:

3LnWJqFW4ihLd2gfJChV3hnp2v2hBsUVXP
 
This address is a multisig escrow address. The site itself doesn't hold your money, they a"
And here is the RegEx that one of you (Mikey I think) provided me with to extract the Bitcoin address into sending_address variable:

Code: Select all

RegExMatch(clipboard,"To the address below:\v+\K\V+",sending_address)
Problem is, it worked flawlessly for a while until it didn't. Now for some reason it returns an empty value into sending_address.
Would one of you (probably Mikey again) be generous enough to write up a different RegEx code I can use as backup whenever the one above doesn't work for some reason?

And how would one go about counting the number of characters in a string? The variable sending_address should have a 34 character count. If it doesn't, something's wrong.

User avatar
boiler
Posts: 16957
Joined: 21 Dec 2014, 02:44

Re: A back-up RegEx please?

Post by boiler » 20 May 2022, 22:00

That code works for that clipboard content, so there is no reason for a “back-up Regex.” You either have something different in the clipboard when it doesn’t work (which you would have to show us) or there’s something else in your script that is causing the problem.

To count the number of characters in a string, use StrLen().

PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

Re: A back-up RegEx please?

Post by PepeLapiu » 20 May 2022, 22:48

boiler wrote:
20 May 2022, 22:00
That code works for that clipboard content, so there is no reason for a “back-up Regex.” You either have something different in the clipboard when it doesn’t work (which you would have to show us) or there’s something else in your script that is causing the problem.

To count the number of characters in a string, use StrLen().
Yeah, it works for me too when I copy the text I posted here into the clipboard. But it doesn't work when I use the same script while copying the same text from the actual page content into the clipboard. So here is what I did as a work around:

Code: Select all

RegExMatch(clipboard,"To the address below:\v+\K\V+",sending_address)
If(StrLen(sending_address)!=34) {
	Array:=StrSplit(clipboard,[A_Space,"`n","`r"]) , temp:=0 , sending_address:=""
	While(sending_address="") {
		temp++
		If(StrLen(Array[temp])=34)
			sending_address:=Array[temp] 
}	}

Descolada
Posts: 1140
Joined: 23 Dec 2021, 02:30

Re: A back-up RegEx please?  Topic is solved

Post by Descolada » 20 May 2022, 23:49

Untested:

Code: Select all

RegExMatch(clipboard,"\b(?:bc)?[13][^\W0OIl]{25,34}\b",sending_address)
Should match anything that looks like a BTC address inside the clipboard: 26-35 character string that starts with 1, 3 or bc, and doesn't contain non-alphanumeric characters and 0, O, I and I.

PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

Re: A back-up RegEx please?

Post by PepeLapiu » 21 May 2022, 00:11

Descolada wrote:
20 May 2022, 23:49
Untested:

Code: Select all

RegExMatch(clipboard,"\b(?:bc)?[13][^\W0OIl]{25,34}\b",sending_address)
Should match anything that looks like a BTC address inside the clipboard: 26-35 character string that starts with 1, 3 or bc, and doesn't contain non-alphanumeric characters and 0, O, I and I.
Oh my! A fella bitcoiner?
I'll try your code when I get to my lappy.
You'll love to hear what I am making.
P2P exchanges like HodlHodl and LocalCryptos are a great concept. But problem is, it takes a good 30 minutes or more to do a trade on those exchanges. So the seller will include that in his pricing by either increasing his % of profit and/or by raising his minimum sell amount.
The seller also has to be near his phone or lappy all the time in case a buyer comes up. And you gotta drop whatever you are doing to serve your buyer.
If not, he moves on and buys from someone else.

And so most traders won't do a trade for under $500, or they raise their premium to ridiculous prices.

So I'm automating the whole thing. I will sell 24/7, always at a lower price than every other trader, and without any waiting for the buyer.

P2P trades, at least in my country, will see trading premiums go down by at least half.

Post Reply

Return to “Ask for Help (v1)”