-2

I am newbie and need a regex for a translation project which helps to search certain text only in lines contains min 1 and max 20 characters. I searched the internet and could not find a satisfactory result. Could you help me? Thank you

For Example:

1 testbtblal balbl al2845 tetete gsgsgs tetet
2 testblablablablal gsgsg gsgs gsgsg gsg
3 blabltetst alets jff            <----- 
4 125testblabal14test ablets blbla
5 test2584blaalj                  <----- Less than 20 characters also contains "bla" text
7 4rblatesbaltest845 testblabla test
8 blabalbal878testbaltesbla blabla test            
9 2584blaal jstba lest            <------
10 blablatest5 45blabla ffftest

There are 10 lines and each one contains "bla" text. But I need to find and replace only bla word in lines less than 20 characters.

Erdem Sarp
  • 41
  • 4

1 Answers1

1

I'm guessing that this simple expression,

^.{21,}$(*SKIP)(*FAIL)|bla

and a replacement of,

SOME_NEW_STRING

might solve the problem. Here, we'd simply find any string longer than 20 chars, then we'd SKIP FAIL, then we'd simply replace bla with anything else that is desired.


If you wish to simplify/modify/explore the expression, it's been explained on the top right panel of regex101.com. If you'd like, you can also watch in this link, how it would match against some sample inputs.


Emma
  • 1
  • 9
  • 28
  • 53