【问题标题】:How to insert space before capitalize character in a word using replace and regex in jquery如何在jquery中使用replace和regex在单词中的大写字符之前插入空格
【发布时间】:2012-07-10 18:46:19
【问题描述】:

这些是数组中的单词

    WorkNumber
    WorkType
    Version 
    Status
    Module
    Priority
    AssignedBy
    AssignedTo
    Subject 
    Details 
    EstimatedTime 
    ActualTime
    CreatedDate
    ModifiedDate

我需要如下输出

Work Number
Work Type
Version 
Status
Module
Priority
Assigned By
Assigned To
Subject 
Details 
Estimated Time 
Actual Time
Created Date
Modified Date

【问题讨论】:

标签: javascript jquery regex


【解决方案1】:

这就是你需要的:

"YourString".replace( /([a-z])([A-Z])/g, "$1 $2");

将输出:

"Your String"

【讨论】:

  • 应该有一个g标志,以防万一。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-20
  • 2019-10-14
  • 2011-07-31
  • 1970-01-01
相关资源
最近更新 更多