首页 \ 问答 \ 正则表达式(Regular expression: limit number of characters)

正则表达式(Regular expression: limit number of characters)

我有一个文本框,需要限制其中的字符数(不超过1000)。
这是我有的正则表达式: ^.{0,1000}$
它很有效,直到文本框中有换行符(当我按下回车键时)。 如果文本框中有换行符,则会向我显示“您有超过2000个字符”的警告。 是否存在此问题的解决方法。


I have a textbox and need to limit number of characters in it (no more than 1000).
This is the regular expression i have: ^.{0,1000}$
it works great until there is a newline in a textbox (when I hit enter). If there is newline in textbox it shows me the warning "you have more than 2000 characters". Is there workaround of this issue.


原文:https://stackoverflow.com/questions/4786902
更新时间:2024-02-24 10:02

最满意答案

遗憾的是,仍然无法通过托管的.Net Framework API进行访问。

更新

这是ADS访问包装器的库\ source:

http://www.codeproject.com/KB/cs/ntfsstreams.aspx


Unfortunately no, there is still no access via a managed .Net Framework API.

Update

Here's a library\source for an ADS access wrapper:

http://www.codeproject.com/KB/cs/ntfsstreams.aspx

相关问答

更多
  • 最简单的选择是使用TPL Dataflow 。 您只需配置一个处理处理的ActionBlock (如果您愿意,可以并行处理), 并将这些项目逐个“异步”地发送给它。 我还建议设置一个BoundedCapacity ,当处理无法处理速度时,它将限制读取器从数据库中读取数据。 var block = new ActionBlock( data => ProcessDataAsync(data), new ExecutionDataflowBlockOptions { ...
  • 不在.NET中 http://support.microsoft.com/kb/105763 #include #include void main( ) { HANDLE hFile, hStream; DWORD dwRet; hFile = CreateFile( "testfile", GENERIC_WRITE, ...
  • 由于缺少Stream API,当前代码并非冗长,而是大量不必要的操作: 初始分配needToRemove = ""; 已过时 您正在维护两个冗余循环变量delCounter和endIndex 你正在使用while循环,尽管你有一个经典的计数循环与初始语句,条件和增量操作,确切的事情, for循环是为 你正在使用long变量的值肯定永远不会超过整数值范围 你有一个过时的try … catch块重新抛出捕获的异常 您不需要使用needToRemove变量来保存一次使用的对象; 你可以简单地检查if(fileDa ...
  • Microsoft已经提供了一个名为StrmExt的shell属性表处理程序。 当然,它不是你想要的,是为Windows 2000和Windows XP编写的,并且必须为64位版本的Explorer重新编译 ,但它包含C ++源代码,它应该给你一个起点,至少。 在Windows Vista中,引入了两个新的API函数,以便更轻松地枚举备用数据流: FindFirstStreamW和FindNextStreamW 。 这些函数的工作方式与Win32中已存在多年的其他FindFirstX和FindNextX类型 ...
  • 遗憾的是,仍然无法通过托管的.Net Framework API进行访问。 更新 这是ADS访问包装器的库\ source: http://www.codeproject.com/KB/cs/ntfsstreams.aspx Unfortunately no, there is still no access via a managed .Net Framework API. Update Here's a library\source for an ADS access wrapper: http://w ...
  • 使用NtOpenFile或NtCreateFile非常容易 例如,在hFile上打开现有ADS NTSTATUS OpenADS(PHANDLE FileHandle, ACCESS_MASK DesiredAccess, HANDLE hFile, PCWSTR Name) { IO_STATUS_BLOCK iosb; UNICODE_STRING ObjectName; RtlInitUnicodeString(&ObjectName, Name); OBJECT_AT ...
  • 您必须在ADTF 2.x和ADTF 3.x及其(adtf)dat文件结构之间有所不同。 ADTF 2.x: 你是对的,你只能用ddl来解释数据。 流必须指向媒体描述中描述的结构。 有时.description文件不完整或缺少从流名称到相应结构的链接。 您可以通过在Harddisk Recorder中启用“选项创建媒体描述”来避免这种情况。 然后* .dat.description将存储在标题相同的* .dat文件旁边,该文件包含正确的流和结构引用,因为它在录制期间可用。 是否有一些关于结构名称的其他信息隐藏 ...
  • 在NTFS中,您可以拥有一个或多个与文件关联的流。 每个人都知道总有一个未命名的流,但您也可以将命名流称为备用数据流(ADS)。 启动svchost并同时使用hiddenProgram.exe 不,它只启动流中包含的程序: svchost:hiddenProgram 如何确保hiddenProgram.exe完全隐藏在任务管理器中 你不能轻易。 所有正在运行的进程都显示在任务管理器中。 请参阅下面的@ joveha评论。 In NTFS you can have one or more streams as ...
  • 尽管未公开度量标准注册表,但您仍可通过其KafkaMetric.value() / KafkaMetric.value(timestamp)方法获取给定KafkaMetric的值。 例如,正如您在JMXRporter中观察到的那样,它将KafkaMetrics列表保留为实例化的init()和metricChange/metricRemoval方法,然后在其MBean实现中,当调用getAttribute时,它将调用其对应的KafkaMetrics.value()功能。 因此,对于您的自定义报告者,您可以应用 ...
  • 幸运的是, FOR /F可以读取ADS: for /f "usebackq" %%C in ("%~f0:colors") do COLOR %%C Fortunately the FOR /F can read ADS: for /f "usebackq" %%C in ("%~f0:colors") do COLOR %%C

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)