Please any one help me achieve this,
I need to implement validation for Amount Text field.
Here's a regex need to allow allows 1-6 digits before and 1-2 digits after the dot.
I had already try with these ways, but I didn't get the solution.
1) http://www.mpatric.com/2012-07-13-fomatting-ios-text-input-on-the-fly
2) regular expression in iOS
I haven't worked on iOS before, so I don't know about iOS specific behavior for regexes. You could check if this works.
^(\d){1,6}\.(\d){1,2}$
Related
I am trying to read a text in a given rectangle using readText() function.
The function works correctly except when it has to read some text which has special characters like ' _ & etc.
I tried using validCharacters with readText() function. But it didn't help.
Code -
put ReadText((287,125,810,164),validCharacters:"_-'.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890") into Login
I tried working with character collections. But that doesn't seem to be right because the text trying to pick is a dynamic text combination of numbers alphabets and a special character. So one cannot create a library of character collection of every alphabet (a-z, A-Z), numbers(0-9) and special characters.
Example of text trying to read:
Login_Userid1_1, Login'Userid1_1
So how do I read such text correctly
Debugging OCR is a bit of an imprecise science. EggPlant has a lot of OCR Parameters to tweak. When designing test cases it's best to try use other mechanisms to gather information whenever possible. ReadText() should be considered a last resort when more reliable methods are unavailable. When I've used it I've often needed to do a lot of trial and error to find the right set of settings, and SearchRectangle to get consistent results. Without seeing exactly what images you are trying to read text from it's difficult to impossible to troubleshoot where the issue might be.
One thing that does stand out to me is that you're trying to read strings that may contain underscores. ReadText() has an optional property IgnoreUnderscores which treats underscores as spaces. By default this property is set to ON. It defaults to ON because some OCR engines have problems identifying underscore characters consistently.
If you want to have ReadText() handle underscores you'll want to explicitly set this property to OFF.
ReadText(rect, validCharacters:chars, ignoreUnderscores:OFF)
I am trying to get a better grasp of delegates and I am trying to create a dollar sign field that begins with the text $0.00, and then fills in the dollar figure as digits are added. For example, typing 4-2-7-5 would produce $0.00, $0.04, $0.42, $4.27, $42.75.
I have created a UITextField and a delegate file for this behavior. I have no idea how to proceed and I am a complete noob in this concept. I found a thread that does explore this concept, but the thread is far more advanced and I don't understand the syntax being used. That question is at: Format a UITextField for currency
I really want to know how to make this happen, but more importantly WHY it works.
I am trying to validate fields in my iOS program:
I need to match a phone number, but the field is optional.
I thought using the regex to match the number to also validate if there is no phone number:
[0-9\-\+\*]{4,14}
Then I thought how to also match where there is either a valid number or no number at all?
(:?[0-9\-\+\*]{4,14})?
Meaning, either match between 4 to 14 chars within the range 0-9,+,-,* or nothing.
This website is showing infinte matches for that pattern.
ideas?
^$|^[0-9\-\+\*]{4,14}$
As to the questions this has brought here:
Regex is a great validation method. and it is cross platform.
no need for another layer of code to implement. Simple and clean.
You should just code it. I don't know your language but basicaly :
If(field.isEmpty)
should do the trick.
I am new to RegEx and need some guidance. Right now I have the following validation for phone numbers:
(\d{3}) ?\d{3}( |-)?\d{4}|^\d{3}( |-)?\d{3}( |-)?\d{4}
Unfortunately, the system I am importing the results into does not think favorably of the numbers being separated solely by spaces or not separated at all. What would the formula look like that requires either dashes or parentheses and accepts only the following formats: XXX-XXX-XXXX or (XXX) XXX-XXXX?
Thank you for your assistance.
Start simple:
\d{3}-\d{3}-\d{4} works beautifully for numbers like 212-867-5309.
As for others, I'd say you and your users would be better off if you kept it simple. No switching, no choices. Pick a standard. Simple is good.
If you must persist, look at this web site for help. You aren't the first.
I have two questions about decimals on my calculator-app:
(1)How do I add a decimal button?
(2)If I type or calculate a big number on the calculator it shows this:
https://www.dropbox.com/s/nuigto6vcok8rtk/Screen%20Shot%202013-10-12%20at%2016.22.44.png
Code: https://www.dropbox.com/sh/zu6ijmbvredssoo/2cH4rzDd3E
The calculator works with buttons
Im using xcode 5
Your post is far too vague. Does your calculator app use an iOS keyboard, or do you have custom buttons? And what do you mean a "decimal button"? You want a button that inserts a decimal place in the number the user is typing?
How you do that depends on how your calculator app works.
I'm not going to download and examine your app for you - sorry. You need to provide a brief, complete explanation of how your app works now, and what you are trying having trouble doing.
As for the output, that's scientific notation, and is a quite common way to display large numbers. The "%g" (or "%G") format string switches to scientific notation automatically if the exponent is large or small enough. Read the description of "%g" in the section of the Xcode docs on "Format Specifiers" for more information.
You probably want to create a custom NSNumberFormatter and use that to format your output number. That will give you more control than you get with stringWithFormat and the like.