Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > BOOK: Beginning Regular Expressions
|
BOOK: Beginning Regular Expressions
This is the forum to discuss the Wrox book Beginning Regular Expressions by Andrew Watt; ISBN: 9780764574894
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Regular Expressions section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2009, 05:30 AM
Registered User
 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default RegEx to match a string only if it does'nt have a particular string within it

Hi All
Requesting help on this one. I am working on a JAVA based tool 'webMethods' which provides built-in functionality to replace char/string from a given input, it also excepts RegEx to match the search string.
My requirement to create a RegEx which can be supplied to the above built-in functionality to match any string (that can contain new lines and other white space characters) only if it doesnt have a particular word say BRANCH.
Examples of positive matches can be-
  • The bank of America.
  • The #123 bank.
  • @$%# (*%&.
Examples of negative matches can be-
  • BRANCH
  • The #123 BRANCH of this bank.
  • This is the last BRANCH.
  • BRANCH BRANCH
I tried using the expression [\s\S\s]*(?!BRANCH)[\s\S\s]*, but this does'nt work for all the scenarios.

Thanks !!
 
Old January 27th, 2009, 05:17 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Well, not to ask a silly question, but...

Why not simply BRANCH for the RegExp and then just test for *NOT* matching instead of for matching in the Java code????





Similar Threads
Thread Thread Starter Forum Replies Last Post
STRING EXACT MATCH ricespn Beginning VB 6 6 November 12th, 2007 01:18 PM
need to match string dynamically dipsut XSLT 2 May 25th, 2007 08:49 AM
use regex to split string store in dictionary edman747 VB How-To 0 January 29th, 2007 12:02 AM
match string in more than one line using Regex suman9730 General .NET 0 October 24th, 2006 02:27 AM
Compier Error: procedure decleration does'nt match haahoou Beginning VB 6 2 January 20th, 2004 03:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.