Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[VB] Like operator not functioning?

New Here ,
Nov 05, 2008 Nov 05, 2008
I'm trying to create the following statement in my VB code, but I'm getting a "Sub or Function not defined" error. My question is, how do you use the Like operator with InDesign scripting? InDesign doesn't seem to recognize the Like operator.

"myCurrentString" contains a letter.

If myCurrentString Like "[A-z]" Then
End If

I'm also trying to do the following:

If myCurrentDigit Like "[0-9]" Then
End If
TOPICS
Scripting
511
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2008 Nov 05, 2008
'You can do this in VBScript...

Dim re
Set re = New RegExp
With re
.Pattern = "[A-Z]"
.Global = True
.IgnoreCase = False
End With
targetString = "A"
msgbox re.Test(targetString)

'8 lines more than you'd like.

'Ben
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 12, 2009 Feb 12, 2009
I couldn't find "RegExp" in the InDesign script model--could you give a bit more information about what this is? I don't know how to iterate through the contents of an XMLElement as individual character objects, so I'm iterating throught XML.contents, putting each character in a basic string variable. I need a way to put strings into a With statement, or a Like operator. I haven't had success with either technique.

Here's an example:

strTime = myCurrentXMLElement.contents
strTime = Trim(strTime)
strLength = Len(strTime)
For counter = 1 to strLength
strTemp = Mid(strTime, counter, 1)
[This is where I need to find out if strTemp is a letter or a digit]

Next
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 13, 2009 Feb 13, 2009
LATEST
RegExp is not part of the Indesign Script Model but a Visual Basic class that handles regular expressions, equivalent of System.Text.RegularExpressions.Regex(pattern, regex_options) in VB.Net.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines