# Substring failing if string contains %'s

**URL:** https://www.finalbuilder.com/forums/t/substring-failing-if-string-contains-s/2717
**Category:** Bugs
**Created:** [November 27, 2006, 2:18am UTC](https://www.finalbuilder.com/forums/t/substring-failing-if-string-contains-s/2717 "2006-11-27T02:18:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![stevage](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stevage](https://www.finalbuilder.com/forums/u/stevage)
#### Post date: [November 27, 2006, 2:18am UTC](https://www.finalbuilder.com/forums/t/substring-failing-if-string-contains-s/2717/1 "2006-11-27T02:18:01Z")

</div>

-Set variable FOO to [%hello] (in the GUI, you type this as “%%hello”  
-String Substring (Specify string, start string=[, end string =] )  
  
  
At runtime, FinalBuilder generates an exception complaining about a mismatched %.  
  
In my actual example, the variable is actually being set by a File Contents Iterator, so I guess I will have to do a search/replace % with %% as a workaround. This isn’t a contrived example, I’m actually parsing a file that has lines starting with %…🙂  
  
Steve

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [November 27, 2006, 3:05am UTC](https://www.finalbuilder.com/forums/t/substring-failing-if-string-contains-s/2717/2 "2006-11-27T03:05:44Z")

</div>

Steve,  
  
What you can do is prevent FB from expanding variables within variables, so for example your file iterator will put each line into a variable, say FileLine, and then you need to pass this into the substring as %FileLine%, but if you use this syntax %!FileLine% then FB will expand FileLine and not attempt to further look for variables within the contents.  
  
hth.

---

<div class="post-metadata">

### Author: ![stevage](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stevage](https://www.finalbuilder.com/forums/u/stevage)
#### Post date: [November 27, 2006, 3:15am UTC](https://www.finalbuilder.com/forums/t/substring-failing-if-string-contains-s/2717/3 "2006-11-27T03:15:11Z")

</div>

Ah, I didn’t know about that syntax, thanks!  
  
Steve
