Sponsored Content
Full Discussion: numeric string and length
Top Forums Shell Programming and Scripting numeric string and length Post 302265735 by dragrid on Monday 8th of December 2008 10:59:26 AM
Old 12-08-2008
numeric string and length

given a string passed to a program that supposed to be numeric and of a certain length say 8 digits - so say for e.g. need to verify this 01234567
How would I parse this string to validat it meet requirements

I tried to use * | sed /\([1-9]\{8})/

Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert string to numeric

Hi, I have read some figures from a text file by getting the position and wish to do some checking, but it seem like it won't work. eg. my figure is 0.68 it still go the the else statement, it seems like it treat it as a text instead of number. Anybody can Help ? Thanks. # only... (3 Replies)
Discussion started by: kflee2000
3 Replies

2. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

3. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies

4. UNIX for Dummies Questions & Answers

Read a string with leading spaces and find the length of the string

HI In my script, i am reading the input from the user and want to find the length of the string. The input may contain leading spaces. Right now, when leading spaces are there, they are not counted. Kindly help me My script is like below. I am using the ksh. #!/usr/bin/ksh echo... (2 Replies)
Discussion started by: dayamatrix
2 Replies

5. Programming

check the given string is numeric or not.

Hi, how to check the given string is numeric or not , without converting ( using strtol...). for ex: if string is C01 - non-numeric data if string is 001 - numeric data TIA (11 Replies)
Discussion started by: knowledge_gain
11 Replies

6. Shell Programming and Scripting

Replace variable length numeric string

I have a customer who logged some cc and bank account numbers in their apache logs. I got the cc numbers x'd out with sed -e 's/args=\{16\}/args=XXXXXXXXXXXXXXXX/g' -e 's/cardnum=\{16\}/cardnum=XXXXXXXXXXXXXXXX/g'but that wasn't too difficult due to the value being 16 digits. The bank account... (7 Replies)
Discussion started by: mk4mzid
7 Replies

7. Shell Programming and Scripting

Extracting numeric from string

I have a file whose contents are: $ cat file1 cfd_V03R37 cfd_V03R38 tried sed 's///g' file1 > file2 $cat file1 0337 0338 Is there any way by which i can work on same file and write o/p to the same file instead of using file2 (3 Replies)
Discussion started by: vjasai
3 Replies

8. Shell Programming and Scripting

how to grep only particular length of numeric values

hi i have two types of file 1. temp.0000000001.data (10 digit numeric) 2. temp.000000001.data (9 digit numeric) i want to search a file which is having 10 digit numeric in between the file name. i use command like this.. ls | grep temp.^*.data but this will give both the files as... (2 Replies)
Discussion started by: somi2yoga
2 Replies

9. Shell Programming and Scripting

check if a string is numeric

I checked all the previous threads related to this and tried this. My input is all numbers or decimals greater than zero everytime. I want to check the same in the korn shell script. Just validate the string to be numeric. This is what I am doing. var="12345" if ) -o "$var" !=... (14 Replies)
Discussion started by: megha2525
14 Replies

10. Programming

C++ Get text and numeric value from a string

I have a string opt="row234" I want to put "row" in a string and 234 in an int. In general it should be opt="textnum" I want to store text in a string and num in an int. (6 Replies)
Discussion started by: kristinu
6 Replies
ISSN(3pm)						User Contributed Perl Documentation						 ISSN(3pm)

NAME
Business::ISSN - Perl extension for International Standard Serial Numbers SYNOPSIS
use Business::ISSN; $issn_object = Business::ISSN->new('1456-5935'); $issn_object = Business::ISSN->new('14565935'); # print the ISSN (with hyphen) print $issn_object->as_string; # check to see if the ISSN is valid $issn_object->is_valid; #fix the ISSN checksum. BEWARE: the error might not be #in the checksum! $issn_object->fix_checksum; #EXPORTABLE FUNCTIONS use Business::ISSN qw( is_valid_checksum ); #verify the checksum if( is_valid_checksum('01234567') ) { ... } DESCRIPTION
new($issn) The constructor accepts a scalar representing the ISSN. The string representing the ISSN may contain characters other than [0-9xX], although these will be removed in the internal representation. The resulting string must look like an ISSN - the first seven characters must be digits and the eighth character must be a digit, 'x', or 'X'. The string passed as the ISSN need not be a valid ISSN as long as it superficially looks like one. This allows one to use the "fix_checksum" method. One should check the validity of the ISSN with "is_valid()" rather than relying on the return value of the constructor. If all one wants to do is check the validity of an ISSN, one can skip the object-oriented interface and use the c<is_valid_checksum()> function which is exportable on demand. If the constructor decides it can't create an object, it returns undef. It may do this if the string passed as the ISSN can't be munged to the internal format. $obj->checksum Return the ISSN checksum. $obj->as_string Return the ISSN as a string. A terminating 'x' is changed to 'X'. $obj->is_valid Returns 1 if the checksum is valid. Returns 0 if the ISSN does not pass the checksum test. The constructor accepts invalid ISSN's so that they might be fixed with "fix_checksum". $obj->fix_checksum Replace the eighth character with the checksum the corresponds to the previous seven digits. This does not guarantee that the ISSN corresponds to the product one thinks it does, or that the ISSN corresponds to any product at all. It only produces a string that passes the checksum routine. If the ISSN passed to the constructor was invalid, the error might have been in any of the other nine positions. EXPORTABLE FUNCTIONS Some functions can be used without the object interface. These do not use object technology behind the scenes. is_valid_checksum('01234567') Takes the ISSN string and runs it through the checksum comparison routine. Returns 1 if the ISSN is valid, 0 otherwise. AUTHOR
Currently maintained by brian d foy "<brian.d.foy@gmail.com>". Sami Poikonen <sp@iki.fi> Original module by Sami Poikonen, based on Business::ISBN by brian d foy. This module is released under the terms of the Perl Artistic License. COPYRIGHT AND LICENSE
Copyright (c) 1999-2008, brian d foy, All Rights Reserved. You may redistribute this under the same terms as Perl itself. perl v5.14.2 2008-08-06 ISSN(3pm)
All times are GMT -4. The time now is 11:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy