• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Third Party Jar - Regular Expression Pattern
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Third Party Jar - Regular Expression Pattern


  • Subject: Third Party Jar - Regular Expression Pattern
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Sat, 29 Mar 2003 15:31:24 +0000

Hi Group,

I'm, using this syntax for regular expressions:
Regex cleaner = new Regex("(?:[\\/:?*\"<>|-]){1,}|(?:\\s+)","_");
in RegEx from the Package com.stevesoft.pat version 1.5 of Regular Expressions in Java


Does any one know how to get this to substitute a backslash from a string because I am getting this returned from my String in the NSLog (everything else substitutes perfectly):

===RegEx Syntax is OK(?:(?:[/:?*\"<>|\-]){1,}(?# <= fast multi)|(?:[ -
]{1,}(?# <= fast multi)){1,})
===The Job Reference No: ///////||A*/*hm:?0?//\\ --01\/:"<> will only be altered if it contains illegal characters for a file or directory name
===Changed Job Reference No to: _A_hm_0_\\__01\_
===The Job Directory Is Named: Job__A_hm_0_\\__01\__ID17 from dbUpdateInMemory()


However, I've even tried to seperate the backslash from the main pattern and give it it's own pattern such as this: (?:[/:?*\"<>|-]){1,}|(?:\\s+){1,}|[?:\\]{1,} but I just get the same results.

The whole point of this code/RegEx Pattern is to eliminate characters that can not be used in a file name, I've also included spaces and hyphens/dashes to be removed

If anyone can help you have my gratitude

Thanks
Jonathan
Ps. This is the String:

public String sJobRefNo() {
String _jobRefNo = (String) tbJobPicture.valueForKeyPath("tbJob.jobRefNo");
Regex stx = new Regex();
try {
stx.compile("(?:[\\/:?*\"<>|-]){1,}|(?:\\s+){1,}");
NSLog.out.appendln("===\r RegEx Syntax is OK" + stx);
} catch(RegSyntax rs) {
NSLog.out.appendln("===\r RegEx Syntax error! There is something wrong with your pattern" + rs);
}


Regex cleaner = new Regex("(?:[\\/:?*\"<>|-]){1,}|(?:\\s+){1,}","_");
NSLog.out.appendln("===\r The Job Reference No: " + _jobRefNo + " will only be altered if it contains illegal characters for a file or directory name");
String cleaned_jobRefNo = cleaner.replaceAll(_jobRefNo);
NSLog.out.appendln("===\r Changed Job Reference No to: " + cleaned_jobRefNo + "");
if (cleaned_jobRefNo.length() > 20) {
return "Job_" + cleaned_jobRefNo.substring(0, 20).trim();
}else
return "Job_" + cleaned_jobRefNo.trim();
}




_________________________________________________________________
Overloaded with spam? With MSN 8, you can filter it out http://join.msn.com/?page=features/junkmail&pgmarket=en-gb&XAPID=32&DI=1059
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Third Party Jar - Regular Expression Pattern
      • From: Art Isbell <email@hidden>
  • Prev by Date: Re: WORepetitions with hyperlink and buttons
  • Next by Date: Re: WORepetitions with hyperlink and buttons
  • Previous by thread: Re: WORepetitions with hyperlink and buttons
  • Next by thread: Re: Third Party Jar - Regular Expression Pattern
  • Index(es):
    • Date
    • Thread