Is valid identifier?
Given a string, determine if it's a valid identifier.
Here is the syntax for valid identifiers:
- Each identifier must have at least one character.
- The first character must be picked from: alpha, underscore, or dollar sign. The first character can not be a digit.
- The rest of the characters (besides the first) can be from: alpha, digit, underscore, or dollar sign. In other words, it can be any valid identifier character.
Examples of valid identifiers:
- i
- wo_rd
- b2h
Examples of invalid identifiers:
- 1i
- wo rd
- !b2h
using System;
using System.Text.RegularExpressions;
public class IdentifierChecker
{
public static bool IsValid(string input)
{
string pattern = @"^[A-Za-z_$][\w_$]+$";
Regex regex = new Regex(pattern);
return regex.IsMatch(input);
}
}
^...$开头和结尾
[A-Za-z_$] 第一个字符的可选范围
[\w_$]后续字符的可选范围
+ 一个或多个重复
| One or more repetitions |
Is valid identifier?的更多相关文章
- IZ65534: 'JAVA.LANG.CLASSFORMATERROR' ERROR FOR A VALID IDENTIFIER
PAR status Closed as program error. Error description Error Message: The java class could not be loa ...
- BASH SHELL not a valid identifier
解决BASH SHELL脚本报错 ‘: not a valid identifier当在shell编辑脚本时,运行时出现了" ‘: not a valid identifier " ...
- iOS 真机测试错误“The application bundle does not contain a valid identifier”
iOS 真机测试错误"The application bundle does not contain a valid identifier" 真机测试的时候报错:"The ...
- bash: export: “path” not a valid identifier [closed]
export SPARK_HOME=/usr/local/spark export PATH=$PATH:$SPARK_HOME/bin bash: export: “path” not a vali ...
- centos6环境远程执行shell脚本报错not a valid identifier的问题处理
# 通过jenkins的apache用户rsync同步php代码到远程服务器报错如下: SSH: EXEC: STDOUT/STDERR from command [/bin/sh /usr/loca ...
- sqlserver the name is not a valid identifier error in function
参考资料:https://stackoverflow.com/questions/22008859/the-name-is-not-a-valid-identifier-error-in-functi ...
- 关于启动bash提示‘bash: export: `//这是新的': not a valid identifier’的解决办法
学习linux以来将centos改的也不少了,也不知道这个问题是由于那个修改来的.最近改bash的操作环境配置文件,用到了~/.bashrc这个文件,发现里面被我修改过. 那是当年安装fcitx输入法 ...
- Python基础(二)
本章内容: Python 运算符(算术运算.比较运算.赋值运算.逻辑运算.成员运算) 基本数据类型(数字.布尔值.字符串.列表.元组.字典.set集合) for 循环 enumrate range和x ...
- linux java 版本
之前linux已经安装了1.6的版本, 我想要升级,于是安装了1.7, /etc/profile 的最后几行是这么写的: JAVA_HOME=/usr/java/jdk1.7.0_79JRE_HOME ...
随机推荐
- iOS开发之runtime的运用-获取当前网络状态
之前写过runtime的一些东西,这次通过runtime获取一些苹果官方不想让你拿到的东西,比如,状态栏内部的控件属性.本文将通过runtime带你一步步拿到状态栏中显示网络状态的控件,然后通过监测该 ...
- Linux 配置网络
1.vi /etc/sysconfig/network-scripts/ifcfg-eth0 2. # Advanced Micro Devices [AMD] 79c970 [PCnet32 LA ...
- HDU 4569 Special equations(数学推论)
题目 //想不出来,看了解题报告 /* 题意:给你一个最高幂为4的一元多项式,让你求出一个x使其结果模p*p为0. 题解:f(x)%(p*p)=0那么一定有f(x)%p=0,f(x)%p=0那么一定有 ...
- HDU 1465 不容易系列之一(错排,递归)
简而言之,就是把n个信封全部装错的可能数.(中问题,具体看题目) //当n个编号元素放在n个编号位置,元素编号与位置编号各不对应的方法数用M(n)表示, //那么M(n-1)就表示n-1个编号元素放在 ...
- jxl.dll操作总结
1)Jxl是一个开源的Java Excel API项目,通过Jxl,Java可以很方便的操作微软的Excel文档.除了Jxl之外,还有Apache的一个POI项目,也可以操作Excel,两者相比之下: ...
- 40页PPT告诉你真正的"互联网+"
点这里 40页PPT告诉你真正的"互联网+" 2015-04-06 网站分析公会 超过50万名互联网从业人士关注 互联网运营领域最具影响力自媒体 本文根据和君赵大伟关于互联网思维大 ...
- java系统属性
java系统属性 1. java.runtime.name:java的运行环境名称. 2. sun.boot.library.path:jdk\jre中的bin的路径 3. java.vm.versi ...
- HTTP常用的状态码
一.200状态码: 成功2××:成功处理了请求的状态码. 1.200 :服务器已成功处理了请求并提供了请求的网页. 2.204:服务器成功处理了请求,但没有返回任何内容. 二.300状态码: 重定向3 ...
- ls 知识点
ls -R 将会以目录的形式列出所有文件,-S 以文件的大小列出所有文件,-t 将会按照修改时间来列出文件,-i 会显示文件的inode
- ffmpeg转码MPEG2-TS的音视频同步机制分析
http://blog.chinaunix.net/uid-26000296-id-3483782.html 一.FFmpeg忽略了adaptation_field()数据 FFmpeg忽略了包含PC ...