简体   繁体   English

如何在jquery中使用replace和regex在单词中大写字符之前插入空格

[英]How to insert space before capitalize character in a word using replace and regex in jquery

these are the words in array 这些是数组中的单词

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

i need the output as following 我需要输出如下

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

This is what you need : 这就是你需要的:

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

Will output : 将输出:

"Your String"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM