Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react'
- const Linky = () => {
- let reg = /[-a-zA-Z0-9@:%._~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_.~#?&//=]*)/g
- let str = '中文www.google.com也是沒問題中文www.googleeee.com也是沒問題'
- let matched = str.match(reg)
- return (
- <div>
- {
- str.split(reg).map(phrase => (
- phrase === ''
- ? <a href={matched[0]}>{matched.shift()}</a>
- : phrase
- ))
- }
- </div>
- );
- }
Add Comment
Please, Sign In to add comment