2015-11-26 51 views
0

如何在路徑路徑中允許所有特殊字符:a-z A-Z和?。!:/ _()'?我試過這個,但它根本不起作用。因爲我想製作一個錯誤報告操作,它發送一封包含當前錯誤描述的電子郵件。如何允許路由中的所有特殊字符(Symfony2)

bugReport: 
path:  /bugReport/{eStatusCode}/{eMessage} 
defaults: { _controller: utilisateurBundle:ExceptionReport:bugReport }  
requirements: 
    eMessage: .[a-zA-Z1-9\-_\/?;!"`'()`\|{}]+ 
options: 
    expose: true 

任何人都可以幫助我嗎?

+0

我覺得你確實需要'eMessage: 「[?!A-ZA-Z0-9 _ /; \」 \''()| {} - ] +「'。 –

回答

0

我想你需要在你的模式中添加引號。

bugReport: 
    path:  /bugReport/{eStatusCode}/{eMessage} 
    defaults: { _controller: utilisateurBundle:ExceptionReport:bugReport }  
    requirements: 
     eMessage: ".[a-zA-Z1-9\-_\/?;!"`'()`\|{}]+" 
    options: 
     expose: true 

這個表達式的在線演示:https://regex101.com/r/vK4rV7/1

+0

謝謝======>我要測試這個 –

相關問題