Help with regexp

Just starting out? Need help? Post your questions and find answers here.
loulou2522
Enthusiast
Enthusiast
Posts: 553
Joined: Tue Oct 14, 2014 12:09 pm

Help with regexp

Post by loulou2522 »

I want to extract this sentence
Annulation dette frs 74 432
(8} Détail des produits et charges sur exercices antérieurs : Charges antérieures Pxet+dice N Produis antnieus
Annulation dette frs 74 432
* Des explications concemant cette rubrique sont données dans la notice n° 2032.
Can someone help me ?
User avatar
jacdelad
Addict
Addict
Posts: 2031
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Help with regexp

Post by jacdelad »

Exactly THIS sentence? Use FindString.

This senctence with variable numbers:

Code: Select all

Annulation dette frs \d+ \d+
Exactly a pair of 2 and 3 numbers:

Code: Select all

Annulation dette frs (\d{2}) (\d{3})
Want to extract the numbers:

Code: Select all

Annulation dette frs (\d+) (\d+)
Gimme some more info!
Last edited by jacdelad on Wed Sep 18, 2024 5:34 pm, edited 1 time in total.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
loulou2522
Enthusiast
Enthusiast
Posts: 553
Joined: Tue Oct 14, 2014 12:09 pm

Re: Help with regexp

Post by loulou2522 »

I can't because
Annulation dette frs 74 432
is not always the same text
User avatar
jacdelad
Addict
Addict
Posts: 2031
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Help with regexp

Post by jacdelad »

Ok, so: 3 words and 2 numbers?

Code: Select all

(\w+ \w+ \w+ \d+ \d+)
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Help with regexp

Post by boddhi »

loulou2522 wrote: I can't because is not always the same text
Be more precise in jour request, please...

[French mode on]
Sois plus précis dans ta demande, STP.
Donne plus d'exemples de chaînes que tu es amené à traiter et ce que tu veux récupérer précisément de manière à pourvoir établir une RegEx exacte.
L'exemple sur 3 lignes que tu as donné est-il une chaîne unique avec des retours de fin de lignes ou est-ce des chaînes récupérées les unes après les autres ?
[French mode off]
 
[Google translate mode on]
Give more examples of the strings you have to process and what exactly you want to retrieve so that you can establish an exact RegEx.
Is the 3-line example you gave a single string with end-of-line returns, or are strings retrieved one after the other?
[Google translate mode off]
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Help with regexp

Post by Marc56us »

I assume the constant is frs and a number that uses space as the thousands separator ?

Code: Select all

 frs ([\d ]+)\r\n
Now all you have to do is add the text you want at the beginning.

Another solution is to use the string functions and read the string backwards, stopping at the first character that is neither a number nor a space.
:wink:
Post Reply