Identify certain string formats

  • Thread starter Thread starter DianePDavies
  • Start date Start date
D

DianePDavies

I have a long list of text strings. Here I want to identify the strings
consisting of:
"1.1.1"
"21.2.3"
"3.2"
"11.4"
i.e. strings with "outline numbers" on level 2 and 3. Is there a simple way
to verify if the complete string is such an outline number?
 
This criteria should identify strings that have a least a number, a
period, and a number anywhere in the string and at the same time exclude
any string that has any character other than a number or a period.

LIKE "*#.#*" AND Not Like "*[!.0123456789]*"

If you want to limit it to levels 2 and 3 then you will have to add
additional criteria. Perhaps checking for more than two periods in the
string.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
There's a number of string evaluation functions you can use.

Instr() - checks a string to see if a substring is present, and returns the
starting position if it is, or 0 if there was no string found.

Left() Mid() and Right() allow you to pull parts of a string from a specific
point

Replace() and Split() allow you to replace certain characters, or split the
string into separate variables.

IsNumberic() evaluates a character or set of characters to see if they are
numberic.

Len() evaluates the length of a string.

I do not know of any pre-defined functions for checking for an 'outline'
format, but between these functions you can build a function to evaluate a
string and see if it is in the format you want. Writing these functions are
often time consuming and take much trial and error to make sure it works
correctly for any string given to the function, but I've written a number of
them for evaluating various formats.


--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
thanks - I forgot to say that I do it in VBA-code - i.e. not with an SQL
statement. I have now hard coded a crude routine that identifies the numbers
and the "."
It works - but is not pretty...
 
If you are just checking for numbers and periods, it should be as easy as this:

Public Function fIsHeader(aString As String) As Boolean
fIsHeader = Iif(IsNumberic(Replace(aString, ".", "")) = True, True, False)
End Function



--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
Jack,

Nice approach, but I think the function you are looking for is:

IsNumeric( )
not
IsNumberic()

--
Dale

email address is invalid
Please reply to newsgroup only.
 
Yea i saw that after I posted it... I figured she might get it figured out
though.

number...numberic... numeric... numer
--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
Back
Top