Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

truncate cursor

Status
Not open for further replies.

LucaFcs

Programmer
Mar 23, 2015
3
IT
Greetings, I have a cursor that contains two lines from a txt file type sdf:
0101010101010
(01)0101010101010
I have to cut the first 5 characters of the second line in your opinion how can I do?
the result should be without (01) 9
0101010101010
0101010101010

greetings
 
While Mikes answer is corect, I dont think you come here to get code to fix a single record. You could browse and simply remove that manually.
What's the more general problem? Removing digit within brackets?

In general for data cleaning operations regular expressions are fine, though not easy to master. You can test against a regular expression using an ole helper class VBScript.RegExp:

Code:
oRE = CreateObject("VBScript.RegExp")
oRE.Pattern = ...your pattern here...
llResult = oRE.test(cValue)

So for example you'll find out what records fields don't match a certain pattern with
Code:
oRE = CreateObject("VBScript.RegExp")
oRE.Pattern = ...your pattern here...

SELECT * FROM table where NOT oRE.test(field)
*or
BROWSE FOR NOT oRE.test(field)

In case you browse you may manually resolve few errors or find a pattern you can code. It helps to know string functions SUBST(), LEFT(), RIGHT(), STRTRAN(), CHRTRAN(), $, AT(), OCCURS(), and some more to do so. The needed code may vary a lot, there is no single cleanup() or fitintopattern() function. What may help is using regular expressions to not only test against a pattern but extract portions fitting a pattern. The Execute Method of the VBScript.RegExp class will use the Pattern as a search pattern and return a collection of matches as object, eg after setting oRE.Pattern you do oMatches = oRE.Execute() and oMatches.Count will give you the count of matches found, which are in oMatches.Item(0) to oMatches.Item(count-1).

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top