Page 1 of 1
Search by format
Posted: Wed Aug 02, 2023 6:41 am
by Natter
Hi,
Is it possible to search in the text by format ?
For example, there is a date in the text in the form of dd/mm/yyyy.
I need to find this fragment and determine that it is exactly the date (a la Excel - mask search "??/??/????")
Re: Search by format
Posted: Wed Aug 02, 2023 8:37 am
by nageswaragunupudi
Use RegEx
Example:
Code: Select all | Expand
cRegExDate := "[0-3][0-9][-|/|.][0-1][0-9][-|/|.][1-2][0-9][0-9][0-9]"
? HB_ATX( cRegExDate, "His date of birth is 20/10/1986, What is his age?" )
// result "20/10/1986"
Re: Search by format
Posted: Wed Aug 02, 2023 8:49 am
by Natter
Great! Thanks !
Re: Search by format
Posted: Wed Aug 02, 2023 9:46 am
by Natter
how to include regular expression unicode characters (for example: « » ) ?
Re: Search by format
Posted: Wed Aug 02, 2023 3:43 pm
by nageswaragunupudi
Are you programming for East Asian languages?
If you are confined to English and West European languages, all characters other than accented characters are represented by a single byte (and the same byte) both in ANSI and UTF8.
So, normal RegEx expressions should work with UTF8 text also, if you are not programming for Asian languages
Re: Search by format
Posted: Wed Aug 02, 2023 3:55 pm
by Natter
That's not how I asked the question.
I am interested in a regular expression for a date of this format
«06» April 2023 (months may be different)
Re: Search by format
Posted: Wed Aug 02, 2023 4:17 pm
by karinha
Re: Search by format
Posted: Thu Aug 03, 2023 3:44 pm
by nageswaragunupudi
Code: Select all | Expand
local cRegEx := "[«][0-3][0-9][»]"
? hb_atx( cRegEx , "test this «23». working" )
Result : "«23»"
Note: These are not Unicode characters.