Answers.Body: <p>The <a href="http://straightupcraft.com/craft-plugins/slugify" rel="nofollow">Slugify</a> plugin has a Twig filter that should do what you're looking for.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-06T00:58:25.610Z
Answers.LastActivityDate: 2015-02-06T00:58:25.610Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm creating an events system &amp; I want to include the venue in the url of the event along with the event name.</p>
  
  <p>For now the venue name is just stored using a plain text field. </p>
  
  <p>Is there an easy way in craft to convert a string &amp; slugify it? Could I use any filter I add to Craft? Can I do it without a plugin of some sort?</p>
  
  <p>I've tried the following</p>
  
  <pre><code>{ (eventVenue ? "-" ~ eventVenue | lower | replace(' ', '-') | replace('/[^\w]/','')) }
  </code></pre>
  
  <p>along with using Twig PCRE</p>
  
  <pre><code>{ (eventVenue ? "-" ~ eventVenue | lower | preg_replace('/[^A-Za-z0-9-]+/') ) }
  </code></pre>
  
  <p>Both of which give the error <code>Expecting name or number</code></p>
  
Tags: <templating><url><format>
Title: How do I use Plain Text Field in URL Format?
ThreadText: # How do I use Plain Text Field in URL Format?
  
  (Asked by: username_0 on 2015-02-06)
  
  I'm creating an events system & I want to include the venue in the url of the event along with the event name.
  
  For now the venue name is just stored using a plain text field.
  
  Is there an easy way in craft to convert a string & slugify it? Could I use any filter I add to Craft? Can I do it without a plugin of some sort?
  
  I've tried the following
  
  ```
  { (eventVenue ? "-" ~ eventVenue | lower | replace(' ', '-') | replace('/[^\w]/','')) }
  
  ```
  
  along with using Twig PCRE
  
  ```
  { (eventVenue ? "-" ~ eventVenue | lower | preg_replace('/[^A-Za-z0-9-]+/') ) }
  
  ```
  
  Both of which give the error `Expecting name or number`
  
  **Tags:** templating, url, format
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-02-06. Score: 2 | Accepted answer
  
  The [Slugify](http://straightupcraft.com/craft-plugins/slugify) plugin has a Twig filter that should do what you're looking for.
  
  
  ---
  
  