Skip to content

Instantly share code, notes, and snippets.

@t0kio2
Created February 21, 2021 19:35
Show Gist options
  • Save t0kio2/062648d0721bf06bb47ce2b7e0a229d4 to your computer and use it in GitHub Desktop.
Save t0kio2/062648d0721bf06bb47ce2b7e0a229d4 to your computer and use it in GitHub Desktop.
import React from 'react';
import { connect } from 'react-redux';
export const withBehavior = Component => connect()(
class extends React.Component {
func = () => console.log('this is hoc')
render() {
return (
<Component
func={this.func}
/>
);
}
},
);
/**
* param "/first/second/../last"
* return "first"
*/
export const getFirstPath = pathname => pathname.match(/^\/([^/]*).*$/)[1];
/**
* param "/first/second/../last"
* return "last"
*/
export const getLastPath = pathname => pathname.match(/([^/]+)\/?$/)[1];
/**
* param 絵文字を含む文字列
* return 絵文字を除外した文字列
*/
export const removeEmoji = (input) => {
const regEmoji = new RegExp(/[\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF]/, 'g');
return input.replace(regEmoji, '')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment