Reputation: 287
I need to find a regular expression that will work with the following dummy input:
Lorem ipsum dolor sit -V amet, consectetuer adipiscing elit.
Aenean commodo ligula Charge Tip eget dolor. Aenean massa.
Cum sociis natoque penatibus et magnis dis parturient montes.
Nascetur ridiculus Charge Tip mus. Donec quam felis,-Vultricies nec.
Pellentesque eu, pretium quis, sem. Nulla consequat massa.
Quis enim. DonecCharge Tippede justo, fringilla vel, aliquet nec.-V
Vulputate eget, arcu. In enim justo, rhoncus ut.
And produce the following result:
Charge Tip -V
Charge Tip -V
Some notes:
I tried many links here already, such as: Regular expression to find two strings anywhere in input
I was unable to get any solution to work as the solutions fail to work on the RegExr site, which I am using to test the regex.
The final result I need is for the regex to work inside Agent Ransack 2014, as I need to search log files on a Windows XP machine.
Upvotes: 1
Views: 1161
Reputation: 48751
Agent Ransack regex engine is Perl compatible. So you can easily search for:
(?-s)Charge Tip(?=.*-V)|(?!\A)\G.*\K-V
Upvotes: 3
Reputation: 4161
Try the following regex, you can see it live here:
^[\w \,\.]*(Charge Tip)[\w \,\.]*(\-V)[\w \,\.]*$
As seen here:
Upvotes: 0