# Regular Expression (.\*?word) doesn't match all lines

**URL:** https://www.finalbuilder.com/forums/t/regular-expression-word-doesnt-match-all-lines/1332
**Category:** Discussion
**Created:** [September 29, 2009, 4:27am UTC](https://www.finalbuilder.com/forums/t/regular-expression-word-doesnt-match-all-lines/1332 "2009-09-29T04:27:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 29, 2009, 4:27am UTC](https://www.finalbuilder.com/forums/t/regular-expression-word-doesnt-match-all-lines/1332/1 "2009-09-29T04:27:50Z")

</div>

I'm trying to a simple Text Find / Replace with the expression&nbsp;(.\*?word) which will match all text from the beginning of the file to 'word' but it will only match the first line.

Any suggestions?

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [September 29, 2009, 6:36am UTC](https://www.finalbuilder.com/forums/t/regular-expression-word-doesnt-match-all-lines/1332/2 "2009-09-29T06:36:35Z")

</div>

Hi Mike   
  
 By default the regex engine is set to single line off and multiline on. You need single line on for this to work. Try adding the single line modifier :   
  
 ((?s).\*?word)   
  
 This works for me.   
  
 HTH

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 29, 2009, 8:14am UTC](https://www.finalbuilder.com/forums/t/regular-expression-word-doesnt-match-all-lines/1332/3 "2009-09-29T08:14:54Z")

</div>

How is the performance?

I&nbsp;am trying to&nbsp;replace ((?s).\*?CUTHERE\*\*\/) with blank space but the step has been running for over&nbsp;20 minutes using 50% CPU on a dual core system.

It's a 1mb&nbsp;.SQL&nbsp;script file so I don't&nbsp;think it should take that&nbsp;long... I'm simply trying to remove all the lines from the beginning of the document to the line that is /\*\*CUTHERE\*\*  
&nbsp;

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 30, 2009, 12:23pm UTC](https://www.finalbuilder.com/forums/t/regular-expression-word-doesnt-match-all-lines/1332/4 "2009-09-30T12:23:25Z")

</div>

if I understand you correctly, you might be much better off using the ‘String Pos’ function to find the position of the CUTHERE part. Save this position to a variable, then using the ‘String SubString’ action to store the text up to that position into a variable. Then do a ‘String Replace’ on that to replace with empty string.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [September 30, 2009, 2:11am UTC](https://www.finalbuilder.com/forums/t/regular-expression-word-doesnt-match-all-lines/1332/5 "2009-09-30T02:11:24Z")

</div>

Hi Mike   
  
 I tested here with a 3Mb text file which had 13000+ matches and it took 1 minute. I’m not sure why it was taking so long for you. If you send us the FB project (with just the text replace action is fine) and the text file then we take a look and see what is happening.   
  
 The good news is I just replaced the regex engine on the action (backported the action from the next version of FB, which uses pcre as the regex engine) and the same action took just over 1 second! I’m not sure yet whether the improvements come from regex engine or some other optimizations done on the action (I removed a lot of code as the new regex engine does a lot more).   
  
 I’ll post here again when a new build with the change is available (in an hour or so).

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [September 30, 2009, 3:12am UTC](https://www.finalbuilder.com/forums/t/regular-expression-word-doesnt-match-all-lines/1332/6 "2009-09-30T03:12:00Z")

</div>

Hi Mike   
  
 Try this build :   
  
 [https://www.finalbuilder.com/downloads/finalbuilder/630/FB630\_1743.exe](https://www.finalbuilder.com/downloads/finalbuilder/630/FB630_1743.exe)   
  
 I have tested the action on this build as much as I could, running side by side with the older build to compare behavior, and so far the only difference I have found is the improved performance.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 6, 2009, 7:23am UTC](https://www.finalbuilder.com/forums/t/regular-expression-word-doesnt-match-all-lines/1332/7 "2009-10-06T07:23:33Z")

</div>

> Posted By Vincent Parrett on 29 Sep 2009 08:12 PM   
> Hi Mike   
>   
> Try this build :   
>   
> https://www.finalbuilder.com/downloads/finalbuilder/630/FB630\_1743.exe   
>   
> I have tested the action on this build as much as I could, running side by side with the older build to compare behavior, and so far the only difference I have found is the improved performance.

That worked wonderfully! Thanks!  
  
&nbsp;
