Alphanumeric and pipe delimiter regular expression validation
i have a header in file like below
EMP_ID|EMP_NAME|DEPARTMENT|SALARY|ACTIVE1
passed to a string
String test = "EMP_ID|EMP_NAME|DEPARTMENT|SALARY|ACTIVE1";
I have to check if the header has only alphanumeric and pipedelimiter is allowed.
other than these i need to raise an error.
Any sugestions.
hi rp0428 thanks for ur suggestion.
yes i found string pattern matching.
public boolean isAlphaNumeric(String s){
String pattern= "^[a-zA-Z0-9]*$";
if(s.matches(pattern)){
return true;
return false;
but i am looking for regexp which matches pipe delimiter as well like
EMP_ID|EMP_NAME|DEPARTMENT|SALARY|ACTIVE1
should return true. else if
EMP_ID , EMP_NAME , DEPARTMENT , SALARY ,, ACTIVE1
other than pipe delimiter like comma or space it should throw error message.
thanks.
Similar Messages
-
Regular Expression Validator Problem
Hi,
I have a text area that I want to use a regular expression
validator on to verify that one or more 9 char alphanumeric serial
numbers were entered.
<mx:RegExpValidator
source="{entryField}"
property="text"
flags="gi"
expression="{/[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0- 9][a-zA-Z0-9][a-zA-Z0-9](
|,|\\n|\\r|\\t)/}"
valid="handleResult(event)"
invalid="handleResult(event)"
trigger="{entryField}"
triggerEvent="textInput"
/>
//for testing
private function
handleResult(eventObj:ValidationResultEvent):void {
if (eventObj.type == ValidationResultEvent.VALID)
entryField.setStyle("borderColor", "green");
entryField.setStyle("borderThickness", "2");
else
entryField.setStyle("borderColor", "red");
entryField.setStyle("borderThickness", "2");
The problem is the handler function always comes back
invalid, even when it should be valid, such as: 123456789 a12345678
lk231jkop
Can anyone advise where I might be going wrong?
Thanks!This is weird, i just tried your RegExp using the Adobe's
Live Docs example and it worked perfectly.
Try it at:
http://livedocs.adobe.com/flex/201/langref/mx/validators/RegExpValidator.html
Scroll down to the end of the page, then type your RegExp and
your TestValue and click the Validate button, it works. I am
guessing that maybe it is your
i
flag, try removing it from your validator.
Hope this helps -
Inline display of error message for a regular expression validation
Hi All,
I am using ApexLib in my application.
I am using regular expression validation for some of the items.
Those validation will happen when the button is pressed and the message will be displayed as per the error.
But, I want the errors to be displayed immediately when the focus is away from that item.
as we do for required items.
could anybody help me to achieve it?
Thanks in advance
bye
SrikaviHi Srikavi,
to achieve a Validation of an item when leaving the field you'll have to use some javascript code (as ApexLib does internally).
What do you need:
- onChange - Event on your Item
- some Javascript code which is called in the onChange Event (you can put this code either in your page html header or, if it is used more often in your application, in a seperate js File)
- call the ApexLib method apexlib.error.showError to display your error
I actually never tried it myself, but i'm pretty sure that this will work (according to what i've seen in the ApexLib code).
Have fun and tell us how it went,
Peter
Edited by: peter_raganitsch on Sep 5, 2008 11:56 AM -
Logical AND in Java Regular Expressions
I'm trying to implement logical AND using Java Regular Expressions.
I couldn't figure out how to do it after reading Java docs and textbooks. I can do something like "abc.*def", which means that I'm looking for strings which have "abc", then anything, then "def", but it is not "pure" logical AND - I will not find "def.*abc" this way.
Any ideas, how to do it ?
BakenFirst off, looks like you're really talking about an "OR", not an "AND" - you want it to match abc.*def OR def.*abc right? If you tried to match abc.*def AND def.*abc nothing would ever match that, as no string can begin with both "abc" and "def", just like no numeric value can be both 2 and 5.
Anyway, maybe regex isn't the right tool for this job. Can you not simply programmatically match it yourself using String methods? You want it to match if the string "starts with" abc and "ends with" def, or vice-versa. Just write some simple code. -
Multiple flat files with Comma delimiter and Pipe Delimiter in the sub folders.
Hi,
I have a directory C:\doc\Outcomes\Health --(This is the main path).
In the path above i have multiple subfolders like
A
B
C
D
Folder A & B have 20 flat files each which are comma separated and pipe delimiter files.
Folder C&D have 20 excel files each.
1) So, In SSIS while looping through the subfolders how do i limit to loop only excel files one time and flat files one time.
2) In folder A&B, how do i loop only Pipe delimiter files (neglecting comma saperated files). I want to loop only pipe delimiter files while using for each loop container.
ThanksBoth are txt files, but the data inside the files is saperated by ',' and '|'. ( comma and pipe)
Thats ok
If delimiters are not consistent you can use this method
http://visakhm.blogspot.in/2014/07/ssis-tips-handling-inconsistent-text.html
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Reset Item After Regular Expression Validation Fails
Apex 4.2
I have a page item (P1_MYITEM) that should only hold alpha charaters, so I have created an item regular expression validation
using
^[a-zA-Z]+$
This works well, but now I want to reset my item (P1_MYITEM) to null
if the validation fails.
Tried using a page process, but they do not run if the validation fails.
Any ideas ?
GusGot it working using
Begin
if not regexp_like (:P1_MYITEM, '^[a-zA-Z]+$')
then
APEX_UTIL.SET_SESSION_STATE('P1_MYITEM',NULL);
return 'Country must be text characters only.';
end if;
End; -
Regular Expression Validator - want to edit an object acct field
The field is a character field. But the field must be editted as follows:
Field must either be 4 numeric numbers with the first position always an 8 so it could be a range from 8000 to 8999
But I must also allow them to enter "8%" or "8n%" or "8nn%" where n represents a number. They want me to allow wild cards.
How would I define this edit on the same field.
1) First Validation: If it has a "%" then the first digit must be an 8 then I can have any of the wild card combinations given above.
2) Second Validation: If no wild card then the field must be in the range from 8000-8999
Is this validation a candidate for Regular Expression Validator or for my own custom method.
If I can code this as a regular expression validator how would I code it. I spent the last day looking on the web for Regular Expression Validator examples.I get the following errors that occur. I can key 8% or 8ddd but when I try these combinations 8d% or 8dd% then the following errors pop up. It gives multiple error but I am just keying on a single line. I can add multiple object lines but just one at a time.
java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- JBO-ObjectCode_Rule_1: Object must be in range 8000-8999 or object must be in form of 8%, 8n%, 8nn% where n represents a number.
- JBO-27008: Attribute set for ObjectCode in view object AccountsecuritygroupobjView2 failed
- JBO-ObjectCode_Rule_1: Object must be in range 8000-8999 or object must be in form of 8%, 8n%, 8nn% where n represents a number.
- JBO-ObjectCode_Rule_1: Object must be in range 8000-8999 or object must be in form of 8%, 8n%, 8nn% where n represents a number.
- JBO-27008: Attribute set for ObjectCode in view object AccountsecuritygroupobjView2 failed
- JBO-ObjectCode_Rule_1: Object must be in range 8000-8999 or object must be in form of 8%, 8n%, 8nn% where n represents a number. -
Hi,
I'm trying to use a regular expression to validate password.
I create a validation in my item called P502_PASSWORD. I choose regular expression type. At the Validation Expression 2, I put this expression:
^(?=.*\d)(?=.*[a-zA-Z])(?!.*[\W_\x7B-\xFF]).{6,15}$
So, I tried to enter a valid "string" at this item. For example: abc123
But it doesn't work and I don't know why. I have another item with a e-mail validation with the expression below, and works:
^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$
So, i really don't know what is happening.
Can someone help me? :)
Thanks,
ViviHi Vivi,
I checked your regex with my favourite application and it seems to be correct for a 'liberal' interpreter. But POSIX-implementation in Oracle seems to be quite strict. At least, I get an ORA-12728 ("invalid range in regular expression") when executing your string with "REGEXP_LIKE". I would take the regex apart bit by bit and see when the regex starts to work with REGEXP_LIKE, like in the following example:
BEGIN
dbms_output.put_line(case when regexp_like('aBc123','^(((\d)|([[:alpha:]])){6,15})$') then 'hit' else 'miss' end);
END;
/This is of course not exactly the expression you wanted, but I guess it's not very far away and produces a 'hit'. ;)
If anybody finds out what exactly caused the error I'd like to know. My first guess was the asterisk in combination with {6,15}, but just removing it didn't do the trick.
-Udo -
Tomahawk Regular expression Validator
Hi,
I am trying to use Tomahawk RegEx Validator in my application.
My questions are as follows.
1. I want to get the pattern of the regular expression from the bean or resource bundle. Is this possible?
2. If I use the pattern as in <t:validateRegExpr pattern='[a-zA-Z\s]+'/> it works perfectly fine. But when I change that to <t:validateRegExpr pattern='\\p{N}+'/> it doesn't work. I want to do this as there won't be any issues with internationalsation.
Please let me know how these issues can be addressed.
Thanks in Advance.
Regards,
Rajamanick_r wrote:
1. I want to get the pattern of the regular expression from the bean or resource bundle. Is this possible?Read the TLD documentation of the tag in question. If the 'pattern' attribute accepts a ValueExpression, then it is possible. I can't directly answer this as you're at a Sun JSF forum, not at an Apache Tomahawk mailinglist.
2. If I use the pattern as in <t:validateRegExpr pattern='[a-zA-Z\s]+'/> it works perfectly fine. But when I change that to <t:validateRegExpr pattern='\\p{N}+'/> it doesn't work. I want to do this as there won't be any issues with internationalsation.Please elaborate "it doesn't work". What did you expect it to do and what did it do unexpectedly instead? Does this pattern work when you just use it in String#matches()? Provide a SSCCE if you can. -
Are there plans to include a validator based on regular expressions in the first releae of JSF. I can imagine many consumers of JSF writing their own if one isn't provided out of the box. I know .NET has such a thing.
I would also like to vote for such a thing.
Does anyone know whether the JSF crew is reading these posts?
I was really wondering why this validator is missing and I fear that it is missing because some JSF people don't want one, since otherwise having a regexp validator would be the most intuitive validator to have.
Some frameworks combine regexp matching with internationalization and localization. This is one aspect that does not really have to be considered with the validators out so far. Maybe that is the reason for why the RegexpValidator is missing.
Also, since JSF needs to be compatible to JDK1.3, there would have to be an extra regexp package like oro to be included within the faces implementation. And someone would have to write a validator using this package for jdk1.3 and another one using the jdk1.4 buildin regexp package. Maybe that's why there is not yet one available... -
Pattern and Matcher of Regular Expressions
Hello All,
MTMISRVLGLIRDQAISTTFGANAVTDAFWVAFRIPNFLRRLFAEGSFATAFVPVFTEVK
ETRPHADLRELMARVSGTLGGMLLLITALGLIFTPQLAAVFSDGAATNPEKYGLLVDLLR
LTFPFLLFVSLTALAGGALNSFQRFAIPALTPVILNLCMIAGALWLAPRLEVPILALGWA
VLVAGALQLLFQLPALKGIDLLTLPRWGWNHPDVRKVLTLMIPTLFGSSIAQINLMLDTV
IAARLADGSQSWLSLADRFLELPLGVFGVALGTVILPALARHHVKTDRSAFSGALDWGFR
TTLLIAMPAMLGLLLLAEPLVATLFQYRQFTAFDTRMTAMSVYGLSFGLPAYAMLKVLLP
I need some help with the regular expressions in java.
I have encountered a problem on how to retrieve two strings with Pattern and Matcher.
I have written this code to match one substring"MTMISRVLGLIRDQ", but I want to match multiple substrings in a string.
Pattern findstring = Pattern.compile("MTMISRVLGLIRDQ");
Matcher m = findstring.matcher(S);
while (m.find())
outputStream.println("Selected Sequence \"" + m.group() +
"\" starting at index " + m.start() +
" and ending at index " m.end() ".");
Any help would be appreciated.Double post: http://forum.java.sun.com/thread.jspa?threadID=726158&tstart=0
-
GUI Based tool for search and replace using regular expression
Hi,
I have developed this small tool which can be used for search and replace in multiple files using reqular expressions.
Features:
1. Full regular expression
2. GUI based with Highlighted results
3. Preview for replace available
4. Pure Java based.
5. Its like unix sed and grep
Please visit below site for download/more information :
http://sourceforge.net/projects/regexsearchrepl/
Thanks,
Hitesh ViseriaI agree with you, it cannot compete grep/sed/awk combination. I couldnt find anything even close to grep/sed for windows which will also have a preview and most important, free. That is what made me write this tool. I am trying to
improve its performance and more features like history etc.
Any suggestions on additional features are most welcome. -
Problem with regular expression validation
hi,
how can i validate folder structure
conditions
no two forward slashes(/) in a sequence no special characters
" /w" and " '/' "
e:/tomcat/ss/ss.text
if(valStr.matches("((['/'])[a-zA-Z0-9_]*)")){
System.out.println("matches");
else
System.out.println("notmatches");
this is no correct .
please give me right solution
with regards
sshI,
/appmg/dd/
is the paths for solaris( starts with /)
i have to test if it is valid path name or not
with regards
ss -
Regular Expression Validation Puzzle
Simple validation of a incomming contact name ..
$contact_name = trim($_POST['contact_name']);
if (!ereg("^([a-zA-Z \'-]+){5,10}$", $contact_name))
{ $errors [] = 'Enter valid contact name'; }
As you can see the name must be u/l case alpha or space,
apostophe or hyphen (I think that is all a name can be) and must be
at least 5 chars and no more than 10 (just testing).
The character validation seems ok and it picks up when there
is less that 5 chars, but the max parameters doesn't seem to work
at all - any ideas?
PS. Is there a routine that strips out more than one space
between words, e.g if someone entered 'John Smith', it would return
'John Smith'?,
Thanks.Hi David,
I have tried this and I am still getting an unexpectred
error:
Joe O'Kane appears on my error message as invalid - Joe
O\'Kane (11 Characters) whilst
Joe O-Kane appears as valid Joe O-Kane (10 Chars)?
I have tried both suggested scripts - my code is ...
$errors = array();
if (get_magic_quotes_gpc())
{ function undoMagicQuotes($array, $topLevel=true)
{ $newArray = array();
foreach($array as $key => $value)
{ if (!$topLevel) { $key = stripslashes($key); }
if (is_array($value)) {$newArray[$key] =
undoMagicQuotes($value, false); }
else { $newArray[$key] = stripslashes($value); }
return $newArray;
$_GET = undoMagicQuotes($_GET);
$_POST = undoMagicQuotes($_POST);
$_COOKIE = undoMagicQuotes($_COOKIE);
$_REQUEST = undoMagicQuotes($_REQUEST);
//if (get_magic_quotes_gpc())
//{function stripslashes_deep($value)
//{ $value = is_array($value) ?
array_map('stripslashes_deep', $value) : stripslashes($value);
//return $value; }
//$_POST = array_map('stripslashes_deep', $_POST); }
$val_cn = trim(preg_replace('/\s+/', ' ',
$_POST['contact_name']));
$val_cn = mysql_real_escape_string($val_cn); // Just want to
see the effect of this function
$cn_html = htmlentities($val_cn); // Just want to see the
effect of this function
if (!preg_match("/^[-a-z'\s]{5,10}$/i", $val_cn))
{ $errors [] = 'Invalid contact name: ' . $val_cn . ' ' .
$cn_html; }
else
{ $errors [] = 'Valid contact name: ' . $val_cn . ' ' .
$cn_html; }
if (sizeof($errors) > 0)
// format and display error list
{ echo "<p class=\"val_err\"> Contact format
error.</p>";
echo "<div class=\"val_err\"><ul>";
foreach ($errors as $e)
{ echo "<li>$e</li>"; }
echo "</div></ul>"; }
Any help much appreciated.
Regards.
Patrick -
How to split a string with a delimiting regular expression like "\r"
Hello!I am a fresh in java programming.Please don't deride my question.What I want to realize is to get the current caret lines and cols in a JTextPane. My question is :After I fetch the string content of the JTextPane and try to split it with the end-line token like "\r" or "\r\n",it always comes me an wrong position.
here is my code:
public void caretUpdate(CaretEvent e) {
int ln,col;
JTextPane textSource = (JTextPane)e.getSource();
String sourceString = textSource.getText();
String subString = sourceString.substring(0,
(e.getDot() == 0) ? 0 : e.getDot()-1);
String[] splitString = subString.split("\r",-1);
ln = splitString.length;
col = e.getDot() - subString.lastIndexOf("\r");
setCaretPosition(ln,col); //display ln and col in a label
I have got puzzled>_<.Please help me.Any help would be appreciated . (^-^)Swing text components always use "\n" to separate lines, not "\r" or "\r\n". When you read text in from a file or paste from the clipboard, the line separators are converted to "\n" if necessary. They save the info about what line separators were used in the source file, so if you write the text back to a file it converts them back.
Maybe you are looking for
-
DVI port not working anymore after latest BIOS update on T410s
Hi all, after installing the most recent BIOS update via ThinkVantage System Update, the DVI port in my T410s does not work anymore. Nvidia and Intel display drivers are in place, and I also checked the BIOS settings, but to no avail. It appears that
-
I have checked and the Adobe Digital Editions is authorized. The library book doesn't expire for another 14 days. These have been the only two suggestions that I have found in other forums. Does anyone have any other suggestions?
-
Itunes Store does not come up when I click on it.
Hi All Frustrated with this one. When I open itunes and click on store, a prompt comes up saying "Itunes could not connect to the itunes store. Make sure your network connection is active and try again". Even though I am connected to the net it still
-
I need a script or something for sending newsletters (asp) - send email in html/plain text - subscribers from database (mssql) - schedule tool would be nice What can you provide?
-
I want to use top-of-page event in my program
Hi, I am using slis type pools.Can anyone describe me how to write the code to diaplay the top-of-page With Regards Ansuman Parhi