Guest User

Untitled

a guest
Nov 23rd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. import React, { Component } from 'react'
  2.  
  3. const Linky = () => {
  4. let reg = /[-a-zA-Z0-9@:%._~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_.~#?&//=]*)/g
  5. let str = '中文www.google.com也是沒問題中文www.googleeee.com也是沒問題'
  6. let matched = str.match(reg)
  7.  
  8. return (
  9. <div>
  10. {
  11. str.split(reg).map(phrase => (
  12. phrase === ''
  13. ? <a href={matched[0]}>{matched.shift()}</a>
  14. : phrase
  15. ))
  16. }
  17. </div>
  18. );
  19. }
Add Comment
Please, Sign In to add comment