Colegas estoy portando una aplicación hecha con xharbour a harbour y Wild2RegEx no existe esta función, hay alguna equivalente ? Muchas Gracias.
Saludos
c:\hbb\source\rtl\regex.c
HB_FUNC( HB_ATX )
HB_FUNC( WILD2REGEX )
HB_FUNC( HB_REGEX )
HB_FUNC( HB_REGEXATX )
HB_FUNC( HB_REGEXALL )
HB_FUNC( HB_REGEXMATCH )
HB_FUNC( HB_REGEXSPLIT )
HB_FUNC( HB_REGEXCOMP )
HB_FUNC( HB_ISREGEXSTRING )
// Test for regular expression functions
// Giancarlo Niccolai
PROCEDURE Main()
LOCAL regex
LOCAL aMatch
LOCAL cStr, nRow := 2, nCol
LOCAL aSource := { ;
"First date to match: 2001-3-21", ;
"2002-12/2", ;
"Another can be 1999/5/12, and succeeds", ;
"Could be 1999/534/12, but this will fail" }
CLS
@ 0, 15 SAY "Regular expression scan tests"
/*
* Standard regex to get the ISO date format:
* ([0-9]{4}): exactly four digits (year); it is in brackets,
* this means that we want it back as a group
* [-/]: one bar or a minus
* ([0-9]{1,2}): one or two digits
*/
regex := hb_regexComp( "([0-9]{4})[-/]([0-9]{1,2})[-/]([0-9]{1,2})" )
FOR EACH cStr IN aSource
@ nRow, 5 SAY "String is '" + cStr + "'"
nRow++
aMatch := hb_regex( regex, cStr )
IF ! Empty( aMatch )
@ nRow, 10 SAY "Matched: " + aMatch[ 1 ] + " ( Year: " + aMatch[ 2 ] + ", Month: " + ;
aMatch[ 3 ] + ", Day: " + aMatch[ 4 ] + ")"
ELSE
@ nRow, 10 SAY "Match FAILED!"
ENDIF
nRow += 2
NEXT
cStr := "searching 'regex' here:"
@ nRow, 5 SAY "A test of a regex compiled on the fly; " + cStr
aMatch := hb_regex( "(.*)regex(.*)", cStr )
nRow++
IF Empty( aMatch )
@ nRow, 10 SAY "NOT FOUND!"
ELSE
@ nRow, 10 SAY "Found (Before: <<" + aMatch[ 2 ] + ">>, After: <<" + aMatch[ 3 ] + ">>)"
ENDIF
nRow += 2
cStr := "A str; with: separators :; here "
@ nRow, 5 SAY "Split test; splitting '" + cStr + "' by ':|;'"
nRow++
aMatch := hb_regexSplit( ":|;", cStr )
IF Empty( aMatch )
@ nRow++, 10 SAY "Test failed"
ELSE
nCol := 10
FOR EACH cStr IN aMatch
@ nRow, nCol SAY cStr + "/"
nCol += Len( cStr ) + 1
NEXT
nRow++
ENDIF
cStr := "A string without separators"
@ nRow, 5 SAY "Split test; splitting '" + cStr + "' by ':|;'"
nRow++
aMatch := hb_regexSplit( ":|;", cStr )
IF Empty( aMatch )
@ nRow++, 10 SAY "Test failed"
ELSE
nCol := 10
FOR EACH cStr IN aMatch
@ nRow, nCol SAY cStr + "/"
nCol += Len( cStr ) + 1
NEXT
nRow++
ENDIF
cStr := "Test for RegexAtX()"
@ nRow, 5 SAY "RegexAtX() test; scanning '" + cStr + "' by 'Reg(.x)'"
nRow++
aMatch := hb_regexAtX( "Reg(.x)", cStr )
IF Empty( aMatch )
@ nRow++, 10 SAY "Test failed"
ELSE
nCol := 15
FOR EACH cStr in aMatch
@ nRow, nCol SAY "FOUND: '" + cStr[ 1 ] + "' Start: " + hb_ntos( cStr[ 2 ] ) + ;
" End: " + hb_ntos( cStr[ 3 ] )
nRow++
NEXT
nRow++
ENDIF
@ nRow, 1
@ MaxRow(), 25 SAY "Press a key to continue"
Inkey( 0 )
RETURN
// Test for regular expression functions
// This allows to use a fine tune regex to use them in programs
// Giancarlo Niccolai
#include "inkey.ch"
PROCEDURE Main()
LOCAL pCompiled
LOCAL cRegex
LOCAL cSentence
LOCAL nRow
LOCAL aMatch, cMatch
LOCAL GetList := {}
SET CONFIRM ON
CLS
@ 2, 15 SAY "Regular expression test"
@ 4, 5 SAY "Insert regular expression(s) and strings to test for."
@ 5, 5 SAY "Press <Esc> to exit"
cRegex := Space( 60 )
cSentence := Space( 120 )
DO WHILE LastKey() != K_ESC
@ 8, 5 SAY "REGEX : " GET cRegex PICTURE "@S30"
@ 9, 5 SAY "PHRASE: " GET cSentence PICTURE "@S60"
READ
IF LastKey() != K_ESC
@ 12, 5 CLEAR TO MaxRow(), MaxCol()
pCompiled := hb_regexComp( RTrim( cRegex ) )
IF Empty( pCompiled )
@ 12, 5 SAY "Invalid REGEX expression"
LOOP
ENDIF
aMatch := hb_regex( pCompiled, RTrim( cSentence ) )
IF aMatch != NIL
@ 12, 5 SAY "MATCHES:"
nRow := 13
FOR EACH cMatch IN aMatch
@ nRow++, 5 SAY ">" + cMatch
NEXT
ELSE
@ 12, 5 SAY "No matches"
ENDIF
ENDIF
ENDDO
CLS
RETURN
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 45 guests