# Option\[String\] to String?

**URL:** <https://community.gatling.io/t/option-string-to-string/959>\
**Category:** Gatling (Open-Source)\
**Created:** [April 15, 2014, 1:16pm UTC](https://community.gatling.io/t/option-string-to-string/959 "2014-04-15T13:16:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juha\_Dahlgren](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@Juha\_Dahlgren](https://community.gatling.io/u/Juha_Dahlgren)\
**Post date:** [April 15, 2014, 1:16pm UTC](https://community.gatling.io/t/option-string-to-string/959/1 "2014-04-15T13:16:10Z")

</div>

Hi,

I’m new to Gatling and scala, and have now been struggeling for too long with following:  
In a request response I want to pick up the “data-lessonstatus” string value, and make some simple char replacement before storing it as session string var “lessonStatus”  
But there seems to be some type mismatch: _.saveAs_ takes a string, but _.transform_ gives a option[String]

.exec(http(“request\_6”)  
.check(regex(""“data-lessonstatus=’([A-Z,0-9,&,#,;]\*)’”"")  
.find.transform( s =\> {  
s.get.replaceAll(“Ö”, “Ö”).replaceAll(“Å”, “Å”)  
s  
}  
.saveAs(“lessonStatus”))

any hints welcome!

---

<div class="post-metadata">

**Author:** ![Nicolas\_R](https://avatars.discourse-cdn.com/v4/letter/n/f14d63/32.png) [@Nicolas\_R](https://community.gatling.io/u/Nicolas_R)\
**Post date:** [April 15, 2014, 1:42pm UTC](https://community.gatling.io/t/option-string-to-string/959/2 "2014-04-15T13:42:21Z")

</div>

Hi,

.check(regex(""“data-lessonstatus=’([A-Z,0-9,&,#,;]\*)’”"")  
.find.transform( _.map(_.replaceAll(“Ö”, “Ö”).replaceAll(“Å”, “Å”) ))  
.saveAs(“lessonStatus”))

Is this working ?  
Do you get it?

cheers  
Nicolas

---

<div class="post-metadata">

**Author:** ![Juha\_Dahlgren](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@Juha\_Dahlgren](https://community.gatling.io/u/Juha_Dahlgren)\
**Post date:** [April 16, 2014, 5:35am UTC](https://community.gatling.io/t/option-string-to-string/959/3 "2014-04-16T05:35:02Z")

</div>

> wow…works perfectly! 🙂 also beautiful solution.
