CSDNRGY
2017-01-09 00:49
采纳率: 99.5%
浏览 4.3k
已采纳

正则表达式如何实现,匹配以*开头的一行?

匹配下面代码中以*开头的行

 public class TransferForm extends BaseObject{
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column GC_TRANSFER_FORM.FORM_ID
     *
     * @mbggenerated Wed Jan 04 13:58:02 CST 2017
     */
    private String formId;

}
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • 已采纳

    /^\s**[^\n]+$/gm,记得加m选项,多行匹配

    
    <textarea id="ta">
        public class TransferForm extends BaseObject{
        /**
        * This field was generated by MyBatis Generator.
        * This field corresponds to the database column GC_TRANSFER_FORM.FORM_ID
        *
        * @mbggenerated Wed Jan 04 13:58:02 CST 2017
        */
        private String formId;
    
        }
    </textarea>
    <script>
        var s = ta.value, mc = s.match(/^\s*\*[^\n]+$/gm);
        console.log(mc)
    </script>
    
    评论
    解决 无用
    打赏 举报
  • 查看更多回答(2条)

相关推荐 更多相似问题