# How to "compose" regexes when writing literals?

**URL:** <https://forums.kodeco.com/t/how-to-compose-regexes-when-writing-literals/196975>\
**Category:** Swift Apprentice: Fundamentals\
**Created:** [October 3, 2023, 2:17pm UTC](https://forums.kodeco.com/t/how-to-compose-regexes-when-writing-literals/196975 "2023-10-03T14:17:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![exchessplayerh](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/exchessplayerh/32/110937_2.png) [@exchessplayerh](https://forums.kodeco.com/u/exchessplayerh)\
**Post date:** [October 3, 2023, 2:17pm UTC](https://forums.kodeco.com/t/how-to-compose-regexes-when-writing-literals/196975/1 "2023-10-03T14:17:38Z")

</div>

Suppose one use a regex as a building block. When using RegexBuilder, one just writes Regex {…}. My question is whether it is possible to do this when writing regex literals.

---

<div class="post-metadata">

**Author:** ![ehabamer](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ehabamer/32/109011_2.png) [@ehabamer](https://forums.kodeco.com/u/ehabamer)\
**Post date:** [October 18, 2023, 3:49pm UTC](https://forums.kodeco.com/t/how-to-compose-regexes-when-writing-literals/196975/2 "2023-10-18T15:49:10Z")

</div>

Sry for the late reply,  
I’m not sure I fully understand, but you can freely write regex literals with RegexBuilder.  
Literals are just a convinient way to represent an object.  
from the [Regex Tutorial](https://www.kodeco.com/36182126-swift-regex-tutorial-getting-started#toc-anchor-010) you can see the first code block in " Capturing Matches" is a big Regex { … } that contains a literal inside it for the new lines.
