Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #4426 > unrolled thread

Remove no numeric chars from string

Started byPaulo Oliveira <paulo@clipinfor.com>
First post2012-12-05 10:31 -0800
Last post2012-12-06 02:59 -0800
Articles 8 — 6 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Remove no numeric chars from string Paulo Oliveira <paulo@clipinfor.com> - 2012-12-05 10:31 -0800
    Re: Remove no numeric chars from string dlzc <dlzc1@cox.net> - 2012-12-05 11:37 -0800
    Re: Remove no numeric chars from string Leo_Bond <l.bond@bk.ru> - 2012-12-05 12:58 -0800
      Re: Remove no numeric chars from string "Urs Eggmann" <Urs.Eggmann@shinternet.ch> - 2012-12-05 22:38 +0100
    Re: Remove no numeric chars from string "Urs Eggmann" <Urs.Eggmann@shinternet.ch> - 2012-12-05 22:20 +0100
    Re: Remove no numeric chars from string "Willie Moore" <williem@wmconsulting.com> - 2012-12-05 18:50 -0600
    Re: Remove no numeric chars from string "Francesco F." <francescangeli.f.remove@remove.gmail.com> - 2012-12-06 07:45 +0100
    Re: Remove no numeric chars from string Paulo Oliveira <paulo@clipinfor.com> - 2012-12-06 02:59 -0800

#4426 — Remove no numeric chars from string

FromPaulo Oliveira <paulo@clipinfor.com>
Date2012-12-05 10:31 -0800
SubjectRemove no numeric chars from string
Message-ID<1f9c00dd-db36-4de4-b134-669c2a522ac9@googlegroups.com>
Hi all,

I have a this code to check if a string have not numeric chars:

FOR i:=1 UPTO SLen(cNif)
 //GARANTIR QUE SO HA NUMEROS
 IF !Between(Asc(SubStr(cNif,i, 1)), 48, 57)
  lResult:=FALSE
  BREAK 1	
 ENDIF	
NEXT i

Now i need to remove the no numeric chars from the string:

PT123 456 789 -----> 12345678

Some ideas
TIA
Paulo Oliveira

[toc] | [next] | [standalone]


#4427

Fromdlzc <dlzc1@cox.net>
Date2012-12-05 11:37 -0800
Message-ID<9a84dab5-732c-4274-b010-79ada0c970eb@googlegroups.com>
In reply to#4426
Dear Paulo Oliveira:

On Wednesday, December 5, 2012 11:31:47 AM UTC-7, Paulo Oliveira wrote:
>
> Now i need to remove the no numeric chars
> from the string:

... Assuming ASCII, and assuming VO has the original Clipper Tools functions...
cNumericOnly := RangeRem( 58, 255, RangeRem( 0, 47, cOrignalString ))

If you need to retain the decimal, you'd need to handle the value 46 differently.

David A. Smith

[toc] | [prev] | [next] | [standalone]


#4428

FromLeo_Bond <l.bond@bk.ru>
Date2012-12-05 12:58 -0800
Message-ID<8594c8fa-ebab-4c64-8551-30d7bf251ec5@googlegroups.com>
In reply to#4426
среда, 5 декабря 2012 г., 22:31:47 UTC+4 пользователь Paulo Oliveira написал:
> Hi all,
> 
> 
> 
> I have a this code to check if a string have not numeric chars:
> 
> 
> 
> FOR i:=1 UPTO SLen(cNif)
> 
>  //GARANTIR QUE SO HA NUMEROS
> 
>  IF !Between(Asc(SubStr(cNif,i, 1)), 48, 57)
> 
>   lResult:=FALSE
> 
>   BREAK 1	
> 
>  ENDIF	
> 
> NEXT i
> 
> 
> 
> Now i need to remove the no numeric chars from the string:
> 
> 
> 
> PT123 456 789 -----> 12345678
> 
> 
> 
> Some ideas
> 
> TIA
> 
> Paulo Oliveira

Hi, Paulo!
Maybe this will help:
FUNCTION StripChars(cStringParameter AS STRING) AS STRING PASCAL

// Strips all non-numeric characters
// StripChars (" (123) 456-78-90") ---> "1234567890"


LOCAL i, dwStringLength AS DWORD

dwStringLength:=SLen(cStringParameter)

FOR i:=1 UPTO dwStringLength
	IF !IsDigit(String2Psz(SubStr3(cStringParameter,i,1)))
		cStringParameter:=Stuff(cStringParameter,i,1,NULL_STRING)
	ENDIF
NEXT

RETURN cStringParameter

Good luck!

[toc] | [prev] | [next] | [standalone]


#4430

From"Urs Eggmann" <Urs.Eggmann@shinternet.ch>
Date2012-12-05 22:38 +0100
Message-ID<ai9t7iFfn08U1@mid.individual.net>
In reply to#4428
Hi Leo

I experimented  also with the func Stuff, but by replacing non digits with 
NULL_STRING inside the loop, the length of string is altered inside the func 
so the wrong characters will be stuffed.

regards
Urs

"Leo_Bond" <l.bond@bk.ru> schrieb im Newsbeitrag 
news:8594c8fa-ebab-4c64-8551-30d7bf251ec5@googlegroups.com...
среда, 5 декабря 2012 г., 22:31:47 UTC+4 пользователь Paulo Oliveira 
написал:
> Hi all,
>
>
>
> I have a this code to check if a string have not numeric chars:
>
>
>
> FOR i:=1 UPTO SLen(cNif)
>
>  //GARANTIR QUE SO HA NUMEROS
>
>  IF !Between(Asc(SubStr(cNif,i, 1)), 48, 57)
>
>   lResult:=FALSE
>
>   BREAK 1
>
>  ENDIF
>
> NEXT i
>
>
>
> Now i need to remove the no numeric chars from the string:
>
>
>
> PT123 456 789 -----> 12345678
>
>
>
> Some ideas
>
> TIA
>
> Paulo Oliveira

Hi, Paulo!
Maybe this will help:
FUNCTION StripChars(cStringParameter AS STRING) AS STRING PASCAL

// Strips all non-numeric characters
// StripChars (" (123) 456-78-90") ---> "1234567890"


LOCAL i, dwStringLength AS DWORD

dwStringLength:=SLen(cStringParameter)

FOR i:=1 UPTO dwStringLength
IF !IsDigit(String2Psz(SubStr3(cStringParameter,i,1)))
cStringParameter:=Stuff(cStringParameter,i,1,NULL_STRING)
ENDIF
NEXT

RETURN cStringParameter

Good luck! 

[toc] | [prev] | [next] | [standalone]


#4429

From"Urs Eggmann" <Urs.Eggmann@shinternet.ch>
Date2012-12-05 22:20 +0100
Message-ID<ai9s62FfflsU1@mid.individual.net>
In reply to#4426
Hi Paulo,

What about:

FUNCTION RemoveNoNum(cNif)
//   e.g.  cNif := "PT 123 A4 555 6 7 8 9 0 "
LOCAL nLen AS DWORD
LOCAL cResult , cTemp AS STRING
LOCAL i AS DWORD
LOCAL aArray AS ARRAY
aArray := {}
FOR i :=1 UPTO SLen(cNif)
    IF Between(Asc(SubStr(cNif , i , 1 ) ) , 48 , 57 )
    // if numeric, save it
        AAdd(aArray , SubStr(cNif , i , 1 ) )
    ENDIF
NEXT i
FOR i :=1 UPTO ALen(aArray)
    cResult += (aArray[i])
    // form the result string
NEXT i
RETURN cResult    // 1234567890


regards
Urs



"Paulo Oliveira" <paulo@clipinfor.com> schrieb im Newsbeitrag 
news:1f9c00dd-db36-4de4-b134-669c2a522ac9@googlegroups.com...
> Hi all,
>
> I have a this code to check if a string have not numeric chars:
>
> FOR i:=1 UPTO SLen(cNif)
> //GARANTIR QUE SO HA NUMEROS
> IF !Between(Asc(SubStr(cNif,i, 1)), 48, 57)
>  lResult:=FALSE
>  BREAK 1
> ENDIF
> NEXT i
>
> Now i need to remove the no numeric chars from the string:
>
> PT123 456 789 -----> 12345678
>
> Some ideas
> TIA
> Paulo Oliveira
>
> 

[toc] | [prev] | [next] | [standalone]


#4432

From"Willie Moore" <williem@wmconsulting.com>
Date2012-12-05 18:50 -0600
Message-ID<k9oq52$sti$1@speranza.aioe.org>
In reply to#4426
Hi Paulo,

Try this function.

Regards,
Willie
Vulcan VIP

FUNCTION RemoveNoNAlpha(cString as String) as String pascal
   LOCAL nLen       AS DWORD
   LOCAL cResult   AS STRING 
   LOCAL  cChar     AS STRING
   LOCAL i             AS DWORD
   cResult     := ""
   nLen         := slen(cString)
   for I := 1 upto nLen
       cChar := substr3(cString,I,1)
       IF IsDigit(cChar)
           cResult += cChar
      ENDIF
  NEXT

  RETURN cResult 

[toc] | [prev] | [next] | [standalone]


#4433

From"Francesco F." <francescangeli.f.remove@remove.gmail.com>
Date2012-12-06 07:45 +0100
Message-ID<k9pf2n$o29$1@news.albasani.net>
In reply to#4426
Hi Paulo,
what about:

LOCAL ret AS STRING

ret := ""
FOR i := 1 UPTO SLen(cNif)
	IF Substr(cNif, i, 1) $ "0123456789"
		ret += Substr(cNif, i, 1)
	ENDIF
NEXT

RETURN ret

HTH,
Francesco






Il 05/12/2012 19:31, Paulo Oliveira ha scritto:
> Hi all,
>
> I have a this code to check if a string have not numeric chars:
>
> FOR i:=1 UPTO SLen(cNif)
>   //GARANTIR QUE SO HA NUMEROS
>   IF !Between(Asc(SubStr(cNif,i, 1)), 48, 57)
>    lResult:=FALSE
>    BREAK 1	
>   ENDIF	
> NEXT i
>
> Now i need to remove the no numeric chars from the string:
>
> PT123 456 789 -----> 12345678
>
> Some ideas
> TIA
> Paulo Oliveira
>
>

[toc] | [prev] | [next] | [standalone]


#4434

FromPaulo Oliveira <paulo@clipinfor.com>
Date2012-12-06 02:59 -0800
Message-ID<bf481903-349d-4f38-ad72-dd3952b6ce5e@googlegroups.com>
In reply to#4426
Thank you all for examples.
Now I have material for my needs.

Paulo Oliveira

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web