수동으로 "https://blockchain.info/tx/a97aaf679880e079f80ddca53044b8cb3bd511014fb09bd28e33d5430dab4c8e"에 문자열 예를 들어
에서 읽기 마지막 64 문자 만 읽으십시오. 송신 코드는 항상 64 자입니다.
정규 표현식
당신이 텍사스-ID를 읽을 수있는 여러 서비스/웹 사이트가있는 경우, 다음 TX-ID가 문자열에서 시작 위치를 저장하고있다가에서 64 자 읽기 그곳에. 당신은 당신이 사용하고자하는 프로그래밍 언어로 말을하지 않았기 때문에, 나는 C++의 예를 보여 드리겠습니다 :
#include <iostream>
#include <string>
#include <vector>
#include <regex>
using namespace std;
struct PositionInString
{
PositionInString(string h, unsigned int p) : host(h), position(p) {}
string host;
unsigned int position;
};
int main()
{
vector<PositionInString> positions;
positions.push_back(PositionInString("blockchain.info", 27));
positions.push_back(PositionInString("btc.blockr.io", 30));
while(true)
{
string url;
cout << "Enter url: ";
cin >> url;
regex reg_ex("([a-z0-9|-]+\\.)*[a-z0-9|-]+\\.[a-z]+");
smatch match;
string extract;
if (regex_search(url, match, reg_ex))
{
extract = match[0];
}
else
{
cout << "Could not extract." << endl;
continue;
}
bool found = false;
for(auto& v : positions)
{
if(v.host.compare(extract) == 0)
{
cout << "Tx-Id: " << url.substr(v.position, 64) << endl;
found = true;
break;
}
}
if(found == false)
cout << "Unknown host \"" << extract << "\"" << endl;
}
return 0;
}
출력 : 스택 오버플로
Enter url: https://blockchain.info/tx/a97aaf679880e079f80ddca53044b8cb3bd511014fb09bd28e33d5430dab4c8e
Tx-Id: a97aaf679880e079f80ddca53044b8cb3bd511014fb09bd28e33d5430dab4c8e
에 오신 것을 환영합니다! 가독성을 높이기 위해 질문의 형식을 편집하여 도움이되는 답변을받을 가능성을 높일 수 있습니다. –