Click here to Skip to main content
15,917,971 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a list of string that contains invoice names,

FACTURE 147-2016 OCP CAMERAS
FACTURE 148-2016 OCP 20 DETECTEURS
FACTURE 150-2016 VIVOENERGY ALTAIR 5X
FACTURE 158-2017 VIVO ENERGY MOHAMMEDIA

I want to compare with the names in the list and the names in an Excel file.

the excel file just contain form

FACTURE 147-2016 or FACTURE150-2016



how cant i compare just with the code and year FACTURE 147-2016

What I have tried:

i try to use ( string.Split , string.contains ) but Sometimes there is space between invoice and code and sometimes not.

FACTURE147-2016
FACTURE 147-2016
Posted
Updated 6-Jul-17 0:22am
v2

If your string could be "FACTURE147-2016" and also "FACTURE 147-2016" (with a space in it) I would use String.Contains in 2 steps :
1st : compare if the string contains "FACTURE"
2nd : if Yes the compare if it also contains "147-2016" ...
 
Share this answer
 
Try a regex:
(?<=FACTURE\s*\d{3}\-\d{4}).*
That should capture just the text part after the invoice code.

Or, if you want the invoice code / year stuff separately
(?<=FACTURE\s*)(?<prefix>\d{3})\-(?<year>\d{4})(?<FreeText>.*)$
Will split it into groups.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900