Randomly Generate alpha-numeric strings?
Hi, can somebody help me to randomly generate strings such as A1, B5, E 2, etc. The range for the values I need generated are [A-E][1-5]. I looked at lots of code for Random generating numbers, but found nothing related to what I need. I hope somebody can help me out here. Thanks!
nevermind, i figured it out! thanks anyway
Similar Messages
-
Check numbers in alpha numeric string
Hi All
Is there any direct command or function module which will find numbers in alpha numeric string or it will check that the string contains only numbers ?
Regards
Yogeshhi,
data: fvalue(4) type c,
nvalue(4) type n.
fvalue = 'ABC1'.
nvalue = fvalue.
if fvalue cn nvalue .
message i000(zz) with 'fvalue contains not Only numbers'.
else.
message i000(zz) with 'fvalue containsOnly numbers'.
endif.
Regards,
Sailaja. -
Removing Non-numeric characters from Alpha-numeric string
Hi,
I have one column in which i have Alpha-numeric data like
COLUMN X
+91 (876) 098 6789
1-567-987-7655
so on.
I want to remove Non-numeric characters from above (space,'(',')',+,........)
i want to write something generic (suppose some function to which i pass the column)
thanks in advance,
MandipThis variation uses the like operators pattern recognition to remove non alphanumeric characters. It also
keeps decimals.
Code Snippet
CREATE FUNCTION dbo.RemoveChars(@Str varchar(1000))
RETURNS VARCHAR(1000)
BEGIN
declare @NewStr varchar(1000),
@i int
set @i = 1
set @NewStr = ''
while @i <= len(@str)
begin
--grab digits or (| in regex) decimal
if substring(@str,@i,1) like '%[0-9|.]%'
begin
set @NewStr = @NewStr + substring(@str,@i,1)
end
else
begin
set @NewStr = @NewStr
end
set @i = @i + 1
end
RETURN Rtrim(Ltrim(@NewStr))
END
GO
Code to validate:
Code Snippet
declare @t table(
TestStr varchar(100)
insert into @t values ('+91 (8.76) \098 6789');
insert into @t values ('1-567-987-7655');
select dbo.RemoveChars(TestStr)
from @t -
OT: Alpha-numeric string after screen-name
What the heck is this string attached to my screen name?? Only appeared after the forum had timed out and had to log back in again.
Weird !I've emailed you privately about this. It appears you have an identity crisis - at least in cyberspace.
There are at least three Nadia Perres, all of them you: Nadia Perre plain and simple, Nadia Perre-39BgI8, and Nadia Perre-NuTcRP (the Community Expert). You need to contact JC (or a shrink) to get things sorted out. -
Format an alpha numeric string
Good day all,
I have what i hope to be a simple question. I have a table that i am storing Latitude and longitude in. The current format for each is as an example N432301 for the Latitude and
W0844150 for the Longitude.
I need the output formated to
N-43-23-01 for Latitude
and
W-84-41-50 for Longitude.GMoney wrote:
Greg,
I ran this using the following:
{code}
with xx as ( select 'N402456' lat, 'W1203926' lon from dual )
select substr(lat,1,1) || '-' || substr(lat,2,2) || '-' || substr(lat,4,2) || '-' || substr(lat,6,2) latitude,
substr(lon,1,1) || '-' || substr(lon,3,2) || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
from xx;
{code}
and the result was :
LATITUDE
LONGITUDE
N-40-24-56
W-20-39-26
which is wrong because in this case the lon was 3 char versus 2 after dropping the '0' from the 084.
That's why I started with "We really need the rules to make sure it's accurate, "
Seriously, if you don't give us good specifics, you can't complain that much if we don't get all your requirements in the first run.
If you confirm that first one is 3 digits, no problem ...
substr(lon,1,1) || '-' || substr(lon,2,3) || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
if you need to drop the 0 on the previous example (again guessing, because you haven't given any real rules )
substr(lon,1,1) || '-' || to_char(to_number(substr(lon,2,3)),'fm999') || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
but at this point, Mike's reg exp shenanigans probably work better
lol
[edit]
Just for completeness:
with xx as ( select 'N432301' lat, 'W0844150' lon from dual union all
select 'N402456' , 'W1203926' from dual
select substr(lat,1,1) || '-' || substr(lat,2,2) || '-' || substr(lat,4,2) || '-' || substr(lat,6,2) latitude,
substr(lon,1,1) || '-' || to_char(to_number(substr(lon,2,3)),'fm999') || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
from xx;
LATITUDE LONGITUDE
N-43-23-01 W-84-41-50
N-40-24-56 W-120-39-26
2 rows selected.
With great requirements, comes great results.
With poor requirements, comes poor results -
Find alpha numeric words with at least 3 words
Hi,
I am trying to extract a string which has got ranges like 10-20 or 10A-20 or A10-20 or 20-A40 or 20-40A or A20-30A and so on. besides this I would want to extract a thrid word which would contain a number or alpha numeric string or again a range alpha numeric string.
for example:
1. abc 123 12-2a cdf
2. efg 23-12 345 alksd
3. klkj; 123 456 asdfg
from the above examples I have to fetch row 1 & 2
Please advice.
Many thanks in advance.
Edited by: 920390 on Mar 12, 2012 8:57 PM920390 wrote:
Hi,
I am trying to extract a string which has got ranges like 10-20 or 10A-20 or A10-20 or 20-A40 or 20-40A or A20-30A and so on. besides this I would want to extract a thrid word which would contain a number or alpha numeric string or again a range alpha numeric string.
for example:
1. abc 123 12-2a cdf
2. efg 23-12 345 alksd
3. klkj; 123 456 asdfg
from the above examples I have to fetch row 1 & 2
Please advice.
Many thanks in advance.
Edited by: 920390 on Mar 12, 2012 8:57 PMIt is a violation of Third Normal Form to store multiple values in a single column!
you reap what you sowed! -
Generating Random Alpha numeric Salt String using MD5 or other algorithm
Hello,
I have a requirement where i need to generate a random alpha numeric salt for MD5 algorithm. Is there a best way to generate this salt ?
The alpha numerics should confine to 5 digits with possible values for each digit being (a-z), (0-9), (A-Z).
Any good random generator for salt would be appreciated.
Thanks.Hi there,
I think the book you read is the book "Java Security", I have that one too.
Please read all those pages before this code.........
In this code, it used the RSA algorithm to do the encryption and JDK DOES NOT support
RSA algorithm....
Beside, this line
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", "BC");It implies the BouncyCastle security provider is in use.... so
www.bouncycastle.org might be a good place to start with....
Good luck! -
How to generate password alpha numeric value
dear friends,
i have written a simple pl/sql to generate a password.
declare
cursor c1 is select * from passwd;
begin
for I in c1
loop
if I.pfno < 3000 then
update passwd set pwd=I.pfno where i.pfno=pfno;
ELSe
update passwd set pwd=lpad(round(I.pfno/20520),4,'0') where i.pfno=pfno;
commit;
end if;
end loop;
end;
In this the pfno is 8 digit alpha numeric. I get password generated when it is only numeric but how could i get if pfno is like 04MAS155.
Kindly help as i have to generate the same as early as possible. I have already been given with procedure to generate random password by our guys but still as i had already generated password to some employees in my concern based on querries like above i request your help to generate for alpha numeric 8 digit number.-- get a random string
FUNCTION string (opt char, len NUMBER)
/* "opt" specifies that the returned string may contain:
'u','U' : upper case alpha characters only
'l','L' : lower case alpha characters only
'a','A' : alpha characters only (mixed case)
'x','X' : any alpha-numeric characters (upper)
'p','P' : any printable characters
RETURN VARCHAR2; -- string of <len> characters (max 60)
PRAGMA restrict_references (string, WNDS); -
Random alpha numeric generation.
i have a requiremnt where i need to generate a random alpha numeric values with the combination of
a - z (lower case)
A - Z (Upper case)
0-9
with out using the dbms_random.string
please help me to get the complete script
Prashant Ki used dbms_random.string('X',6) statement but it generates the alphanumeric with upper case. i wanted the combination of lower,upper and digits. as shown below.
e.g aB3cdFE88
to get the above i did some thing like this.
select dbms_random.string('L',4)||dbms_random.string('X',6) as rand_alphanumeric from dual
here i am concatinating the two strings.
i want to know is there any way other than this to geneate random alphanumeric values ? -
Unique random alpha num string
Hi Guys,
I have a unique question.
I need to generate a unique random Alpha Num string.
I cannot use 0,5,8 and 0,S,B in the generated output string.
The string generated should be no more than length 7 max
Pls help.Following solution generates random unique strings combinations
from any given base set. Here is a sample output.
$ java UniqueStringGenerator 7 100 10
FCT2RYT
2M31BU8
VV8FU4Z
BON2MKE
OKUJZT0
68E8X8S
YTNLZAY
CPEKPFP
C176M24
GQB9QE9The idea is quite simple.
Pre-work:
1. The base set is first mixed to increase entropy.
2. All possible combinations are divide up into random buckets.
Work for every unique string:
1. Pick a bucket at random.
2. Get next number in bucket.
3. Convert the number to a unique string token.
It is possible to adjust how much entropy you want in your
sequence of generated combinations by choosing how many buckets
the generator contains. However, every bucket will take up some
memory.
import java.util.*;
import java.math.*;
public class UniqueStringGenerator {
public static String[] ALPHA_NUM =
{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
"Q","R","S","T","U","V","X","Y","Z",
"0","1","2","3","4","5","6","7","8","9"};
private List _parts = null;
private List _buckets = null;
private int _length;
private BigInteger _range = null;
public UniqueStringGenerator(String[] parts, int length,
int numberOfBuckets) {
_length = length;
// mixing the base set to increase entropy
_parts = new Vector();
List all = new Vector();
for (int i = 0;i < parts.length;i++) {
all.add(parts);
while (all.size()>0) {
int p = (int)(((double)all.size())*Math.random());
_parts.add(all.get(p));
all.remove(p);
// dividing all possible numbers into given number of buckets
BigInteger numParts = BigInteger.valueOf(parts.length);
_range = BigInteger.ONE;
for (int i = 0;i<_length;i++) {
range = range.multiply(numParts);
TreeSet starts = new TreeSet();
Random rand = new Random();
while (starts.size()<numberOfBuckets-1) {
BigInteger bi = new BigInteger(_range.bitLength(), rand);
if (bi.compareTo(_range)<=0) {
starts.add(bi);
_buckets = new Vector();
Bucket last = new Bucket(BigInteger.ZERO);
_buckets.add(last);
for (Iterator i = starts.iterator();i.hasNext();) {
Bucket next = new Bucket((BigInteger)i.next());
_buckets.add(next);
last.setTo(next.getStart());
last = next;
last.setTo(_range);
private class Bucket {
private BigInteger _start;
private BigInteger _next;
private BigInteger _to;
public Bucket(BigInteger start) {
_start = start;
_next = start;
public void setTo(BigInteger to) {
_to = to;
public BigInteger getStart() {
return _start;
public boolean hasNext() {
return next.compareTo(to)<0;
public BigInteger next() {
BigInteger ret = _next;
next = next.add(BigInteger.ONE);
return ret;
public String toString() {
return "["+start+", "+next+", "+_to+"]:"+hasNext();
public String nextUnique() {
// getting next big integer
BigInteger left = null;
while (left==null) {
Bucket b = (Bucket)
buckets.get((int)(Math.random()*buckets.size()));
if (b.hasNext()) {
left = b.next();
// converting it to a combination
StringBuffer unique = new StringBuffer();
BigInteger base = BigInteger.valueOf(_parts.size());
for (int i = 0;i<_length;i++) {
BigInteger[] resRem = left.divideAndRemainder(base);
left = resRem[0];
unique.append(_parts.get(resRem[1].intValue()));
return unique.toString();
public static void main(String[] args) {
if (args.length!=3) {
System.out.println("Usage: UniqueStringGenerator "+
"[string size] [# buckets] [# prints]");
return;
int length = Integer.parseInt(args[0]);
int numBuckets = Integer.parseInt(args[1]);
int num = Integer.parseInt(args[2]);
UniqueStringGenerator usg = new UniqueStringGenerator
(UniqueStringGenerator.ALPHA_NUM, length, numBuckets);
for (int i=0;i<num;i++) {
System.out.println(usg.nextUnique()); -
Restating my issue / question...
When I send email from this iMac, there is a string of characters assigned. The characters are all the "alpha numeric" characters on the QWERTY key board. This only occurs when email is sent from this iMac. The issue does not manifest when using any other lap top or computer.
Hence, I have ruled out the issue is a yahoo mail matter.
Again, I can access the Yahoo mail account form multiple devices and send email without unintended assignment of character strings, but when I send wmail using this iMac, the issue happens everytime.
Characters are stacked verticaly in a column. It looks as if all characters (except function keys) are included in the string.
Any ideas?
GMcPlease read this whole message before doing anything.
This procedure is a diagnostic test. It won’t solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
Third-party system modifications are a common cause of usability problems. By a “system modification,” I mean software that affects the operation of other software — potentially for the worse. The following procedure will help identify which such modifications you've installed. Don’t be alarmed by the complexity of these instructions — they’re easy to carry out and won’t change anything on your Mac.
These steps are to be taken while booted in “normal” mode, not in safe mode. If you’re now running in safe mode, reboot as usual before continuing.
Below are instructions to enter some UNIX shell commands. The commands are harmless, but they must be entered exactly as given in order to work. If you have doubts about the safety of the procedure suggested here, search this site for other discussions in which it’s been followed without any report of ill effects.
Some of the commands will line-wrap or scroll in your browser, but each one is really just a single line, all of which must be selected. You can accomplish this easily by triple-clicking anywhere in the line. The whole line will highlight, and you can then copy it. The headings “Step 1” and so on are not part of the commands.
Note: If you have more than one user account, Step 2 must be taken as an administrator. Ordinarily that would be the user created automatically when you booted the system for the first time. The other steps should be taken as the user who has the problem, if different. Most personal Macs have only one user, and in that case this paragraph doesn’t apply.
Launch the Terminal application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
When you launch Terminal, a text window will open with a line already in it, ending either in a dollar sign (“$”) or a percent sign (“%”). If you get the percent sign, enter “sh” and press return. You should then get a new line ending in a dollar sign.
Step 1
Triple-click the line of text below to select it:
kextstat -kl | awk '!/com\.apple/{printf "%s %s\n", $6, $7}' | open -f -a TextEdit
Copy the selected text to the Clipboard by pressing the key combination command-C. Then click anywhere in the Terminal window and paste (command-V). A TextEdit window will open with the output of the command. Post the contents of that window, if any — the text, please, not a screenshot. You can then close the TextEdit window. The title of the window doesn't matter, and you don't need to post that. No typing is involved in this step.
Step 2
Repeat with this line:
{ sudo launchctl list | sed 1d | awk '!/0x|com\.(apple|openssh|vix)|org\.(amav|apac|cups|isc|ntp|postf|x)/{print $3}'; sudo defaults read com.apple.loginwindow LoginHook; } | open -f -a TextEdit
This time you'll be prompted for your login password, which you do have to type. Nothing will be displayed when you type it. Type it carefully and then press return. You may get a one-time warning to be careful. Heed that warning, but don't post it. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
Note: If you don’t have a login password, you’ll need to set one before taking this step. If that’s not possible, skip to the next step.
Step 3
launchctl list | sed 1d | awk '!/0x|com\.apple|org\.(x|openbsd)/{print $3}' | open -f -a TextEdit
Step 4
ls -1A /e*/mach* {,/}L*/{Ad,Compon,Ex,Fram,In,Keyb,La,Mail/Bu,P*P,Priv,Qu,Scripti,Servi,Spo,Sta}* L*/Fonts 2> /dev/null | open -f -a TextEdit
Important: If you formerly synchronized with a MobileMe account, your me.com email address may appear in the output of the above command. If so, anonymize it before posting.
Step 5
osascript -e 'tell application "System Events" to get name of every login item' | open -f -a TextEdit
Remember, steps 1-5 are all copy-and-paste — no typing, except your password. Also remember to post the output.
You can then quit Terminal. -
How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).
How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).
-
Removing non-alpha-numeric characters from a string
How can I remove all non-alpha-numeric characters from a string? (i.e. only alpha-numerics should remain in the string).
Or even without a loop ?
Extract from the help for the Search and Replace String function :
Right-click the Search and Replace String function and select Regular Expression from the shortcut menu to configure the function for advanced regular expression searches and partial match substitution in the replacement string.
Extract from the for the advanced search options :
[a-zA-Z0-9] matches any lowercase or uppercase letter or any digit. You also can use a character class to match any character not in a given set by adding a caret (^) to the beginning of the class. For example [^a-zA-Z0-9] matches any character that is not a lowercase or uppercase letter and also not a digit.
Message Edité par JB le 05-06-2008 01:49 PM
Attachments:
Example_VI_BD4.png 2 KB -
Check string for alpha numeric
is there a direct way to check whether the string is alpha numeric?
private boolean isAlphaNumeric(String str){
boolean blnNumeric = false;
boolean blnAlpha = false;
char chr[] = null;
if(str != null)
chr = str.toCharArray();
for(int i=0; i<chr.length; i++){
if(chr[i] >= '0' && chr[i] <= '9'){
blnNumeric = true;
break;
for(int i=0; i<chr.length; i++){
if((chr[i] >= 'A' && chr[i] <= 'Z') || (chr[i] >= 'a' && chr[i] <= 'z')){
blnAlpha = true;
break;
return (blnNumeric && blnAlpha);
Hope this would solve your problem -
The senders names appear to be random generated so I can't block one name. I am getting 10 to 20 per day. How vcan I stop it?
You might try this program.
SpamSieve
Maybe you are looking for
-
Error while activating a persistent class
Hi, I have created a persistent class and included fields of the custom table in persistent mapping. But when I tried to activate the class I am getting the following error Method IF_OS_FACTORY~CREATE_TRANSIENT has already been implemented. Pls sugge
-
Formating an excel file by BSP Download
I have made a BSP application which can dowload file into an excel file.But now i have a requirement in which i have to format the excel file with colour and cell width.I have to colour the column header of the excel file with some colours like blue
-
My iphone 4 after upgrade to ios 5 it dies oftenly,
none of the button works I just take the phone out of my pocket and find nothing working and had to try to reset the phone by pressing home and power button. it happened 4 times already after i upgraded to ios5 my phone is just 2 months old
-
I'm getting an error when running a fairly basic VI to acquire a sequence from the PCI-1409 card. It is -1074397110 Exhausted resources (general). It's occurring in the 'generate pulse' bit. As far as resources go, the number of buffers in MAX is sti
-
VOD movie resume starts at the beginning....
We rented a VOD movie last night. Half way through watching it we got a phone call so I paused the movie. 5 minutes or so after pausing a message came up saying the pause had timed out and live TV reappeared. A few minutes later I went back to th