by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/jsup-2-1-investor-s-relief-experiment-on-separation-of-investment-and-sns Hello, this is @joviansummer(witness: @jswit). I'm starting a new experiment regarding my @jsup vote service. The purpose of this experiment is to separate STEEM investment and social interaction(posting/commenting). For many people, writing a post daily(literally 365 posts per year) is not easy. It's not fun, and mandatory daily post only written for self-voting delegation service tends to result in useless low-quality content. I hope this new function of @jsup will reduce those posts, and also make it a bit more easy to invest in STEEM without worrying about daily posting. I think pressure of daily posting significantly undermines Steem as SNS. It's not fun. This is how it works: From 11:45 PM to 11:50 PM every night(reference time zone is GMT+9), @jsup checks if eligible delegators wrote something and received daily v...
파이썬에서 정규표현식(regex)을 이용한 문자열 검색
- Get link
- X
- Other Apps
by joviansummer
original STEEMIT post: https://steemit.com/blog/@joviansummer/regex
파이썬에서 정규표현식(regular expression)을 이용해서 검색 조건에 일치하는 문자열인지 확인하는 방법입니다.
예시를 보겠습니다. 문자열 'abc', 'def', '123', '1abc' 이렇게 4개를 묶어 리스트(list)로 만들고 영문 소문자([a-z])를 검색해 봅니다.
import re
# 리스트 생성
str_list = ['abc', 'def', '123', '1abc']
# 적용할 정규표현식을 컴파일하여 regex에 할당
regex = re.compile('[a-z]')
이제 for 반목문으로 str_list에 속한 문자열들에 대해서 검색을 합니다. 우선 match()를 사용해 봅니다.
for i in str_list:
if regex.match(i):
print(i)
abc def
match()는 문자열 처음부터 조건과 일치하는지 검색합니다. 위의 예시에서는 문자열 'abc'와 'def'가 처음부터 영문 소문자로 시작하므로 조건에 부합하여 줄력되었습니다.
search()는 문자열 전체에 대해 일치하는 부분이 있는지를 검색합니다.
for i in str_list:
if regex.search(i):
print(i)
abc def 1abc
문자열 '1abc'의 경우 영문 소문자로 시작하지 않기 때문에 match()에서는 조건에 부합하지 않지만, 영문 소문자를 포함하고 있으므로 search()에서는 조건에 부합되어 출력됩니다.
findall()은 조건에 맞는 문자열을 모두 찾아서 리스트 형태로 가져옵니다.
x = 'hello'
y = regex.findall(x)
print(y)
['h', 'e', 'l', 'l', 'o']
문장으로부터 영문 소문자 단어를 분리하려면 아래와 같이 해 볼 수 있겠습니다.
# 영문 소문자가 1번 이상 반복: 정규표현식 [a-z]+
regex2 = re.compile('[a-z]+')
x = 'my name is joviansummer.'
y = regex2.findall(x)
print(y)
['my', 'name', 'is', 'joviansummer']
Popular posts from this blog
스티미언의 영향력 지수 계산
by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/5qvaqw 오늘 이런 저런 생각을 하다가 문득 떠오른 내용인데, 잊어버리기 전에 적어 둡니다. 스티미언이 스팀 생태계에 행사할 수 있는 정량적인 영향력에 대해 생각해 보았습니다. 좋은 글을 많이 썼다거나 서비스를 개발했다거나 아는 사람이 많다거나 이런 정성적인 영향력과는 별도로, 수량으로 표시할 수 있는 영향력에 대한 것입니다. 일단 직접적인 수량은 보유한 스팀파워입니다. 예를 들어 50만sp를 보유하고 있다면, 아마 고래라고 칭해도 될 것 같습니다. 그런데, 조금 더 생각해 보면 영향력을 보유한 스팀파워만으로 측정하여 고래라고 간주하는 것은 과도하게 단순화시킨 감이 없지 않습니다. 현재 수량화된 측면에서 스팀 생태계에 영향력을 행사할 수 있는 방법은 2가지가 있습니다. 이 2가지 방법은 스팀파워를 지닌 스티미언 모두에게 유효합니다. 첫번째 방법은 업보팅입니다. 스티미언은 나에게 크게 보팅해 주는 사람의 의견에 영향을 받을 수밖에 없습니다. 큰 스팀파워로 보팅해 주는 스티미언이 많을 수록 커뮤니티가 활성화되고 신규 사용자가 유입될 가능성이 높아집니다. 방글라데시 커뮤니티가 실제 사례라고 할 수 있을 것 같습니다. @jungjunghoon님의 일파만파 운동은 보팅의 영향력을 확대하여 커뮤니티를 활성화하려는 시도라고 생각됩니다. @jsup의 후원 보팅 기능도 이러한 취지로 개발되었습니다. 두번째 방법은 증인투표입니다. 스팀 블럭체인은 증인들이 운영하는 서버(증인 노드)에 의해 유지되기 때문에, 누가 블럭체인을 유지할 것인지를 결정하는 증인투표는 일종의 주권 행사라고 할 수 있습니다. 최상위 증인 20명은 한달에 약 1만스팀을 증인 보상으로 받게 됩니다. 서버 운영비를 충당해야 되므로 1만스팀 전체가 수익이 되는 것은 아니지만 그래도 상당한 수입입니다. 하위 증인들은 순위에 따라 보상을 받는데 21위라고 해도 한달에 ...
GentBG - why bother to burn STEEM?
by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/gentbg-why-bother-to-burn-steem GentBG - a new experiment to burn STEEM Hello, this is @joviansummer(witness: @jswit). I'd like to briefly explain why I bothered to start @gentbg experiment. Unlike bitcoin, STEEM has no supply limit. As long as STEEM exists, newly minted STEEM will be added to total supply. If we can't maintain corresponding demand or reduce supply, downward pressure on STEEM price can be a big challenge. @gentbg project is an experiment to reduce STEEM supply by burning. @gentbg will burn liquid author reward and delegate SP reward to @jsup to get amplified upvotes. The main purpose is to create a perpetual STEEM burning loop. I added a bit of fun factor via AI-generated images, to incentivize giving upvotes to @gentbg's posts. If you have some spare voting power, you can contribute to burning STEEM by giving upvotes to @gentbg's posts. Initial run of this experiment wil...
jsup/avle code update - you don't have to write post everyday
by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/jsup-avle-code-update-you-don-t-have-to-write-post-everyday Hello, this is @joviansummer, developer of @jsup and@avle voting service. Voting service code for @jsup and @avle has been updated. I had been considering this update for a while, and recently I could come up with detailed implementation plan which resulted in a relatively swift code revision. The new added feature is capability to give daily upvote to the first thing you write for the day(timezone GMT+9) regardless of post or comment/reply. Writing a post everyday can be challenging. In that case, you can write a reply to receive daily upvote because writing a reply everyday is much easier and also a good way to engage in your community. Writing a post everyday just to get an upvote can be very tedious and exhausting, and post itself could easily become low-quality. There may be people who enjoy writing a post everyday, but we can't ignore th...
Comments
Post a Comment