Search for bytes that are located before a set of found bytes Programming Software Development by random_1 … only works with int right? then i saw `lookahead` and `lookbehind` but i don't understand the docs. any help will… negative lookbehind regex problem Programming Software Development by diafol Hi all, am using a regex (in php), but I'm all confused. I'm trying to replace a string ('di') with 'deu'. SImple enough, but I don't want a replacement if 'di' is preceded by 'io' as in 'iodine', 'iodic', 'iodide' etc. This is what I have: [CODE]'/(?<!io)di/i'[/CODE] It works fine for everything, but unfortunately it doesn't stop the 'iodi'… Re: negative lookbehind regex problem Programming Software Development by d5e5 Rather than struggle to compose one regex that does all the substitution I would use two regexes. I find it easier to understand and change if necessary.[CODE]#!/usr/bin/perl use strict; use warnings; my @words = qw(iodine Thiodi number dix Iodic iodide); foreach my $word(@words){ $word =~ s/(?<!io)di/deu/i;#Replace di with deu … Re: negative lookbehind regex problem Programming Software Development by diafol Thanks d5e5, I'll give it a go. I'll need to change code to php but looks strightforward. Will get back to you. Shorten a regex lookahead and lookbehind Programming Software Development by trishtren Hello, im currently working on a program to split a string based on symbols only, i need to seperate the string around the symbols whilst keeping the symbols as well eg. test_String_123_^; would result in an array containing : [test] [_] [String] [_] [123] [_] [^] However although i have achieved it with this code : exampelstring.split(&… Re: Shorten a regex lookahead and lookbehind Programming Software Development by masijade How about not using split, and, instead, using pattern and matcher with `(([^_^]+)?([_^])?)` i.e. package bogustest; import java.util.regex.Matcher; import java.util.regex.Pattern; public class BogusTest { public static void main(String[] args) { String test = "test_String_123_^"; Pattern… Re: Shorten a regex lookahead and lookbehind Programming Software Development by masijade As a note though, '^' is a special character ONLY when used as the first character within square brackets, and an '_' is NOT a special character, at all, so there was no reason for the \\\\ occurances in your initial regex. Re: Shorten a regex lookahead and lookbehind Programming Software Development by sepp2k > '^' is a special character ONLY when used as the first character within square brackets `^` means "beginning of the line" outside of square brackets, so it does need to be escaped. You're right about `_` though. Re: Shorten a regex lookahead and lookbehind Programming Software Development by masijade Ach, yeah, idiot. Inside square brackets it does NOT need to be escaped, however (unless it is to be the only character in the brackets, otherwise, simply do not make it the FIRST character within those brackets). Re: Matching "pi" but not "pie" Programming Software Development by MattEvans …(?![\w\d]))|3.14|g [/inlinecode] It has a negative lookbehind (?<![\w\d]) and lookahead (?![\w\d]) for characters preceeding… Re: Need some help composing objects at runtime Programming Software Development by vidaj … like a charm :D Changed the regex to use negative lookbehind and lookahead to match the +, and a new regex to… Re: Regular expression Programming Software Development by marcinkuptel Thanks Gribouillis! Your solution works very well. I found something even simpler though. It's called the 'negative lookbehind assertion'. [code=python] print re.split(r"(?<!\\)\^", 'Autocolli\^sion:No^Pack\^age:10DB15')[/code] The above line produces: ['Autocolli\\^sion:No', 'Pack\\^age:10DB15'] Re: Help me regarding preg_replace Programming Web Development by pritaeas … would be the best method for this, possibly a negative lookbehind. You can read about it here: [url]http://www.regular… Re: find and replace Programming Web Development by hielo … tutorial, read about Positive and Negative Lookahead Positive and Negative Lookbehind but for what you are trying to do, you need… Re: Matching 01010 with regex /010/? Programming Software Development by d5e5 … use strict; use warnings; my $str = '01010'; #When 10 found, 'lookbehind' to see if 0 precedes it. #If 0 precedes the… Re: Java Split Text by Spaces and Punctuation Programming Software Development by ~s.o.s~ It's possible to include exceptions by using [negative lookbehind assertion feature of regular expressions.](http://www.regular-expressions.info/… Re: Why there is no spell check for posts and comments ? Community Center Meta DaniWeb by deceptikon … good parser, but there are quirks that make lookahead and lookbehind tricky. I may not need to do anything clever to… Re: Program - To find the longest word from a sentences Programming Software Development by deceptikon … punctuation. To properly do it would require some lookahead and lookbehind, and even then poorly formatted sentences could cause an issue… Re: Give a visual interface (GUI) to a console exe file Programming Software Development by Garidius Hello Suzie, Many thanks for your suggestion. I think C and C++ for what I investigated, don't handle lookbehind, lookahead or PCRE compatible regex. I'll check about C# since you mention that is very very easy to create a GUI :). Regards