似乎几种现存的中文编程语言都不得劲,是什么原因造成现在的局面,是中文语法问题,还是硬件,还是语言自身缺陷?
无论什么语言,最终都要翻译成 计算机能识别的的机器语言,中文编程作为高级语言,难点就在于它翻译成机器语言的成本很高,而且相关配套的开发工具,编译工具等都需要从头开发,并且没有可行的市场,也就是没有组织愿意开发了
正则表达式:描述了一种字符串匹配的模式,可以用来检查一个字符串中是否含有某种子串、将匹配的子串替换或者从某个串中取出符合某个条件的子串等。
以输入英文短句(英文单词+空格)为例:
#include "stdafx.h"
#include "iostream"
#include <regex>
using namespace std;
bool CheckStrFormat(std::string strFormat, std::string strCheck);
bool CheckStrFormat(std::string strFormat, std::string strCheck)
{
std::regex base_regex(strFormat);//正则表达式
std::smatch base_match;//存放匹配的字段
return std::regex_match(strCheck, base_match, base_regex);
}
int _tmain(int argc, _TCHAR* argv[])
{
string tmpstr = "And take things in stride.";
if (!CheckStrFormat("^[A-Za-z\\s\\.]+$", tmpstr))
{
cout << "字符串中除了字母和空格外还含有其他特殊字符,解析错误" << endl;
return false;
}
cout << tmpstr << endl;
system("pause");
}
if (!CheckStrFormat("^[A-Za-z\\s\\.]+$", tmpstr))
中的"^[A-Za-z\\s\\.]+$"
可以根据自己的需求进行配置.
|
![]() | |
---|---|
如果有班车还需要私家车类似道理,中文编程系列必须要有这是正道理。
中文编程语言难产的原因是什么?难产这个归复产科负责