perl regex from AS

Hi.
I’m trying to do something like this:

Put a string into variable inputText via dialog display.
Then use a do shell script to call perl regex and check if inputText is characters only
If it is, display dialog OK. else NOT OK.

I have no idea how to use variable inputText in do shell script.

Help me please.

Have a nice day.

It depends. What you want to do after something happens. This one errors when a character is not an alphabet.


property a : "abcdefghijklmnopqrstuvwxyz"
--
display dialog "Enter whatever:" default answer "something"
set user_input to text returned of result
repeat with this_char in user_input
	if (contents of this_char) is not in a then
		beep 3
		error "bad character"
	end if
end repeat

gl,

Thanks for help
To tell the truth I want to check measurement units in InDesign.
I thought regex may help.
For example. I have display dialog and I can put there anything. I want check if it is millimeter or inch or point or pica point.
So I want to check this via regex and if there is a “mm” or " mm" or “in” or etc. then a script make a conversion to this unit.

I don’t know how to use my variable from AS in regex.

AppleScript has conversion units. Not too many post questions about it.

Thanks for clue, but it doesn’t solve my input text validation problem via regex :slight_smile:

I need to check if text contains or not a unit. When it is: “12 mm”, “12mm”, "12 mm " then it’s ok, but “12 mm d23” then it should be entered again.

Here’s some info:

http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.39.html

gl,

Thanks for clue, but it doesn’t solve my input text validation problem via regex :slight_smile:

I need to check if text contains or not a unit. When it is: “12 mm”, “12mm”, "12 mm " then it’s ok, but “12 mm d23” then it should be entered again.

Here’s some info:

http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.39.html

gl,

There is no pica point or point, but there is no problem for now.
Now i want to use regex to validate string via applescript :slight_smile:

Oh, I see what you’re saying. You should use AppleScriptStudio. Getting user input takes a lot o work sometimes. Instead use the ui and you can restrict what type of data they enter.

gl,

Are you saying that “mm n” where n is some number is the only allowable string?

If so, you just need to sheck if it starts with "mm " and the rest of the text is an integer.

gl,