Clipboard has a page of text and numbers and special characters. however somewhere in text exist, any integer, 0-99(space)dollars
example;
88 dollars
5 dollars
0 dollars
30 dollars
I need help to Regex code tso that Clipboard = "the number before dollars"
from above examples
Clipboard = 88
Clipboard = 5
Clipboard = 0
Clipboard = 30
extracting something from text using regex
Re: extracting something from text using regex
Code: Select all
Clipboard := ""
Clipboard := "88 dollars"
ClipWait, 1
MsgBox,, before, % Clipboard
RegExMatch(Clipboard, "\d{1,2}(?= dollars)", match)
MsgBox,, after, % Clipboard := match
Re: extracting something from text using regex
your code failed to give me the result im looking for, perhaps I didnt explain correctly.Xtra wrote: ↑24 Jul 2021, 13:41Code: Select all
Clipboard := "" Clipboard := "88 dollars" ClipWait, 1 MsgBox,, before, % Clipboard RegExMatch(Clipboard, "\d{1,2}(?= dollars)", match) MsgBox,, after, % Clipboard := match
I will try once more
Clipboard = ; entire page of text, numbers & special characters approximately 1500 characters.
Somewhere in the text appears a single or 2 digit (0-99) followed by (space) and the word dollars.
i want a regex code, to remove all except for the integer thats before dollars so
x = clipboard
msgbox, %x% must diplay thsi 1or 2 digit number
Re: extracting something from text using regex
You only need this part. (everything above these lines was just to show as an example)
Copy your text to the clipboard and then run the code.
Code: Select all
RegExMatch(Clipboard, "\d{1,2}(?= dollars)", match)
MsgBox,, after, % Clipboard := match
Re: extracting something from text using regex
[Mod edit: quote tags fixed.]Xtra wrote: ↑24 Jul 2021, 15:50You only need this part. (everything above these lines was just to show as an example)Code: Select all
RegExMatch(Clipboard, "\d{1,2}(?= dollars)", match) MsgBox,, after, % Clipboard := match
dear friend how can include above regex code in my script without message box so that
x = match
Re: extracting something from text using regex
Code: Select all
RegExMatch(Clipboard, "\d{1,2}(?= dollars)", match)
x := match
Code: Select all
RegExMatch(Clipboard, "\d{1,2}(?= dollars)", x)