
Coding
文章平均质量分 65
羁士
后端开发工程师
展开
-
Golang 不规范时间格式的转换
Golang 不规范时间格式的转换go语言在处理年月日时间格式的时候,总是需要按照官方规范的格式进行定义,且不支持变更,这在很多场景下是不能适应的,比如处理excel时的日期格式总数2021/7/15,但是官方包只支持解析"2006/01/02",也就是说月份必须是两位数,难道要我匹配补齐两位数吗?很麻烦有没有!然后发现轮子早已被造好,这个库支持各种各样的时间格式,甚至是英文和汉字,太????了。https://github.com/araddon/dateparse用起来也很简单,直接Parse原创 2021-07-17 14:15:14 · 1259 阅读 · 0 评论 -
Golang正则表达式不支持复杂正则和预查问题解决
Golang正则表达式不支持复杂正则和预查问题解决我有一个需求,需要匹配一段字符串中第几季的这个几,那么按正则表达式的语法,我的表达式应该是这样的`(?<=第)\d+(?=季)`然而,当我用go官方包regexp的时候,compile的时候报了个错误:error parsing regexp: invalid or unsupported Perl syntax: (?<啥意思呢?语法错误,不支持(?<,然而我在线运行的时候明明是没错的,这说明go的正则引擎不支持负向预查原创 2021-07-15 21:17:05 · 9139 阅读 · 4 评论 -
Redis和memcache有什么区别与不同?如何选择?
问:Redis和memcache都是常用的缓存工具,但他们有哪些不同你知道吗?平常应用中怎么选择呢?先说结论,我认为他们有以下几方面的不同:1、Redis和Memcache都是将数据存放在内存中,memcache还可用于缓存其他东西,例如图片、视频等等,但最大只能缓存1M。Redis最大缓存可达512M。2、Redis不仅仅支持简单的k/v类型的数据,同时还提供lis...原创 2020-01-06 15:18:29 · 1092 阅读 · 0 评论 -
每日一练之Reverse Integer[LeetCode No.7]-翻转整数
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your function原创 2017-04-26 14:20:41 · 322 阅读 · 0 评论 -
每日一练之Longest Common Prefix【LeetCode No.14】——求字符串的最长公共前缀
题目:Write a function to find the longest common prefix string amongst an array of strings.分析:只需用第一个字符串与后面的进行比较,最大长度不能大于第一个字符串的长度class Solution {public: string longestCommonPrefix(vector& s原创 2017-05-15 22:36:55 · 677 阅读 · 0 评论 -
每日一练之Roman to integer & integer to Roman【LeetCode No.12,13】
Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question.class Solution原创 2017-05-04 16:55:38 · 280 阅读 · 0 评论 -
每日一练之poor pigs【leetcode No.458】——猪测毒问题
There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes. What is the minimum原创 2017-05-12 11:38:30 · 1703 阅读 · 0 评论 -
每日一练之Remove Element【LeetCode No.27】—删除数组相应值
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.原创 2017-04-19 10:12:20 · 398 阅读 · 0 评论 -
每日一练之Palindrome Number【LeetCode No.9】—判断是否为回文数
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of convertin原创 2017-04-19 10:55:51 · 274 阅读 · 0 评论 -
每日一练之Two sum [leetcode No.1]
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sam原创 2017-04-17 20:40:23 · 383 阅读 · 0 评论