I created loggin panel and now i wanna check that username is only string. In other case i want to return "Bad username". So How can I check that textfield is only string ?
I am not sure what exactly you mean by if the username is a string?
If by string, you mean that your username consists of only characters i.e. A-Z (or a-z). You can check if each character in your username have the ascii value between 65 to 90 (for A-Z) or 97 to 122 (for a-z). If you want to allow any other characters such as underscore (ascii 242), add that also to the test.
Related
I have some hotels that contains characters which are not valie for when i want to insert these hotel names as a file name as file naming doesn't allow /, * or ? and want to know what this error means.
text?text
text?text
text**text**
text*text (text)
text *text*
text?
I am trying to use an if else statement so that if a hotel name contains any of these characters, then replace them with -. However I am receiving and error stating a dangling ?. I just want to check if I am using the replace correctly for these characters.
def hotelNameTrim = hotelName.toString()
if (hotelNameTrim.contains("/"))
{
hotelNameTrim.replaceAll("/", "-")
}
else if (hotelNameTrim.contains("*"))
{
hotelNameTrim.replaceAll("*", "-")
}
else if (hotelNameTrim.contains("?"))
{
hotelNameTrim.replaceAll("?", "-")
}
replaceAll accepts a regex as a search pattern. * and ? are special characters in regex and need to be escaped with a back slash. Which itself needs to be escaped in a Java string :)
Try this:
hotelNameTrim.replaceAll("[\\*\\?/]","-")
That will replace all you characters with a dash.
I get a string from a message /whisper
The string contains password:name:nameInHex
I want to find the first variable in the string and compare it with the password trigger and if the trigger == first variable in the string then continue to nr4 in the list.
I want to find the second variable in the string, name and convert it to hex.
I want to compare name with nameInHex and if it is true, then continue to invite the person to by using a chat command /invite
Split the string when you reach each colon, and store them their respective variables.
Then have your logic to process each once you have them stored in a variable
http://lua-users.org/wiki/SplitJoin
Start with
password,name,nameInHex=mystring:match("^(.-):(.-):(.-)$")
I have a table in DB2 say METAATTRIBUTE wherein a column say "content" might contain any special character including the unicode characters.
For any special character, Eg: "#" I can simply search by :
Select * from METAATTRIBUTE where content like '%#%';
but how to search for unicode characters like "u201B" or "u201E" ???
Thanks in advance.
Assuming you are talking about DB2 LUW, the Unicode string literals are designated by the symbols "u&", followed by a regular string literal in single quotes. Unicode code points are designated by an escape character, backslash by default. For example:
$ db2 "values u&'\201b'"
1
---
‛
1 record(s) selected.
So your query would look like:
Select * from METAATTRIBUTE where content like u&'%\201b%';
Recently, I have had the same problem. This worked for me
select *
from METAATTRIBUTE
where MEDEDELINGSZONE like '%' || UX'201B' || '%'
I meet a stange charactor,It has 122 bytes.
<script>
var pig ="ฏ๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎ํํํํํํํํํํํํํํํํํํํํํํํํํํํํํํํํํํ";
alert(pig.length) ;
</script>
The result is 122! oh,my god.
It make the web page disordered.
Its not a character its a string containing 122 characters, its actually 366 bytes in size. the string is made up of 3 characters, 1 ฏ some ๎ and the rest in ํ. I think they're Thai characters since chrome asks if I want to translate it from Thai.
see http://jsfiddle.net/mowglisanu/6b6VY/
I'm in need of the ability to parse and separate a text string using Sensetalk (the scripting language the Eggplant GUI tester uses). What I'd like to be able to do is provide the code a text string:
Put "MyTextIsHere" into exampleString
And then have spaces inserted before every capital letter save for the first, so the following is then stored in exampleString:
"My Text Is Here"
I basically want to separate the string into the words it contains. After searching the documentation and the web, I'm no closer to finding a solution to this (I agree, it would be far easier in a different language - alas, not my choice).
Thank you in advance to anyone who can provide some insight!
See question at http://www.testplant.com/phpBB2/viewtopic.php?t=2192.
With credit to Pamela at TestPlant forums:
set startingString to "HereAreMyWords"
set myRange to 2 to the number of characters in startingString // The range to iterate over– every character except the first
Put the first character in startingString into endString // The first character isn't included in the repeat loop, so you have to put it in separately
repeat with each character myletter of characters myRange of startingString
if charToNum(myLetter) is between 65 and 90 // if the character's unicode number is between 65-90...
Put space after endString
end if
Put myLetter after endString
end repeat
put endString
or you could do it this way:
Put "MyTextIsHere" into exampleString
repeat with each char of chars 2 to last of exampleString by reference
if it is an uppercase then put space before it
end repeat
put exampleString