简体   繁体   中英

look behind for this REGEX?

im putting the delimiter i want to split by in caps just so they will stand out code should search for upper or lowercase

$ReadStr = 'asbhd dbshd ABC/DEF sdjfhjskjhfh hfjhd fkj GHI/JKL sdhjkjhfg'; 

this is what I have...

$SplitStr = preg_split("[.../+...]",$ReadStr);

print_r($SplitStr);

would output:

asbhd dbshd
sdjfhjskjhfh hfjhd fkj
sdhjkjhfg

just not sure how to implement the look behind the same exact regex expression...

this is the output i'm looking for:

asbhd dbshd 
ABC/DEF sdjfhjskjhfh hfjhd fkj 
GHI/JKL sdhjkjhfg

Use a look-ahead instead:

/(?=...\/+...)/

Or to be more specific:

/(?=[a-z]{3}\/+[a-z]{3})/i

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM