Reputation: 21
I want to match this: exclude one character, exclude one space, then 4 spaces
here is what I tried but does not work
[^a-z0-9]{1}[^ ]{1}[ ]{4}
I just want the 4 spaces, but before those 4 spaces there should be one character and one space, I don't know if I can
Upvotes: 0
Views: 62
Reputation: 2085
For increased portability (look-behinds aren't supported everywhere), readability, and simplicity, try this regex.
(?:\w\s)(\s{4})
The first matching group will be your spaces as desired.
Upvotes: 0
Reputation: 31011
You wrote exclude, but I suppose you want to:
If this is the case, use the following regex:
[a-z0-9] ([ ]{4})(.*)
The four spaces (after initial char and space) will be in capture group #1 and the rest of the text will be in capture group #2.
Upvotes: 0
Reputation: 91518
If I well understand your need, this will do the job:
(?<=\w ) {4}
This is matching 4 spaces preceeded by an alphanumeric character and a space
Upvotes: 1
Reputation: 1653
This regex matches four spaces if they're preceeded by a lowercase letter/digit and one space.
(?<=[a-z0-9] ) {4}
Upvotes: 0