Search by format

Search by format

Postby Natter » Wed Aug 02, 2023 6:41 am

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 "??/??/????")
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Search by format

Postby nageswaragunupudi » Wed Aug 02, 2023 8:37 am

Use RegEx
Example:
Code: Select all  Expand view
  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"
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10259
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Search by format

Postby Natter » Wed Aug 02, 2023 8:49 am

Great! Thanks !
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Search by format

Postby Natter » Wed Aug 02, 2023 9:46 am

how to include regular expression unicode characters (for example: « » ) ?
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Search by format

Postby nageswaragunupudi » Wed Aug 02, 2023 3:43 pm

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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10259
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Search by format

Postby Natter » Wed Aug 02, 2023 3:55 pm

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)
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am


Re: Search by format

Postby nageswaragunupudi » Thu Aug 03, 2023 3:44 pm

Code: Select all  Expand view
local cRegEx := "[«][0-3][0-9][»]"
? hb_atx( cRegEx , "test this «23». working" )
 

Result : "«23»"
Note: These are not Unicode characters.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10259
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 15 guests