PDA

View Full Version : انتخاب همه متن بجز قسمت مشخی توسط regex



Jason.Bourne
دوشنبه 16 دی 1387, 22:44 عصر
میخوام که توسط regex همه قسمتهای یک متن را انتخاب کنم. البته بجز یک کلمه مشخص.

مثلا در پاراگراف زیر، بجز کلمه "activity" ، همه پاراگراف انتخاب بشه.

Last account activity: 4 hours ago on this computerLast account activity: 4 hours ago on this computerLast account activity: 4 hours ago on this computerLast account activity: 4 hours ago on this computerLast account activity: 4 hours ago on this computer

به عبارتی، حاصل کار بشود
Last account : 4 hours ago on this computerLast account : 4 hours ago on this computerLast account : 4 hours ago on this computerLast account : 4 hours ago on this computerLast account : 4 hours ago on this computer

برای درست کردن الگو (pattern)، مشکل دارم.

mehdi.mousavi
چهارشنبه 23 آذر 1390, 11:46 صبح
سلام.
می تونید از این الگو استفاده کنید:


\b(?!activity)\S+

موفق باشید.

پاورقی: میدونم تاپیک قدیمیه، اما یا باید پاکش می کردم (چون بی پاسخ مونده بود)، یا بهش جواب می دادم. دومی رو ترجیح دادم.