首页 \ 问答 \ 密码强度正则表达式与数字[重复](Password strength regex with numbers [duplicate])

密码强度正则表达式与数字[重复](Password strength regex with numbers [duplicate])

这个问题在这里已经有了答案:

我正在进行强度密码测试,并试图检查密码是否包含大写和小写字符。 我使用了两个正则表达式,他们几乎都在工作; 代码只是在这里:

    var upper = false;
    var lower = false;
    var upperCase= new RegExp('[^A-Z]');
    var lowerCase= new RegExp('[^a-z]');
    


    if (password.match(upperCase )){
        upper = true;    
    }
    if (password.match(lowerCase)){
        lower = true;
    }

当我输入数字或只输入一个数字时,如“1”,上下变为真。

我用正则表达式不太好,我犯了一个错误吗?


This question already has an answer here:

I'm working on a strength password test, and I'm trying to check if the password has upper, and lower, case characters. I'm using two regular expressions, and they're almost working; with the code just here:

    var upper = false;
    var lower = false;
    var upperCase= new RegExp('[^A-Z]');
    var lowerCase= new RegExp('[^a-z]');
    


    if (password.match(upperCase )){
        upper = true;    
    }
    if (password.match(lowerCase)){
        lower = true;
    }

When I'm typing numbers, or just a digit, like "1", upper and lower become true.

I'm not really good with regex, did I made a mistake?


原文:https://stackoverflow.com/questions/40828226
更新时间:2022-08-20 11:08

最满意答案

我认为你以错误的方式使用sizeof和指针。

sizeof(dc)sizeof(dc->array)可以替换为sizeof(MyClass)ArraySize * sizeof(int)

对于指针,你必须做两次cudaMemcpy来获得你的数组。

  1. 首先获取对象hc,它存储数组的addr。

    cudaMemcpy(&hc, dc, sizeof(MyClass), cudaMemcpyDeviceToHost);
    
  2. 然后获取数组本身。

    cudaMemcpy(h_array, hc.array, ArraySize*sizeof(int),D2H);
    

此外, dc是指向设备mem的指针。 你不能在主机上取消引用它,就像这个dc->array


I think you use sizeof and pointers in a wrong way.

sizeof(dc) and sizeof(dc->array) in your code could be replaced by sizeof(MyClass) & ArraySize * sizeof(int).

For pointers, you have to do cudaMemcpy twice to get your array.

  1. First get object hc, which stores the addr of your array.

    cudaMemcpy(&hc, dc, sizeof(MyClass), cudaMemcpyDeviceToHost);
    
  2. Then get the array itself.

    cudaMemcpy(h_array, hc.array, ArraySize*sizeof(int),D2H);
    

Also, dc is a pointer to device mem. You can not dereference it on the host like this dc->array

相关问答

更多
  • 你在做什么是无效的,你应该听警告: 无法在主机函数中直接读取__device__变量devAr 首先让我简化您的代码,只显示显示问题所需的大小: #include __device__ int devAr[1]; int main() { devAr[0] = 4; std::cout << devAr[0] << std::endl; } 现在发生了什么: __device__ int devAr[1]; 在设备内存中分配固定大小的数组,并将指向此设备内存的指针 ...
  • 我认为你以错误的方式使用sizeof和指针。 sizeof(dc)和sizeof(dc->array)可以替换为sizeof(MyClass)和ArraySize * sizeof(int) 。 对于指针,你必须做两次cudaMemcpy来获得你的数组。 首先获取对象hc,它存储数组的addr。 cudaMemcpy(&hc, dc, sizeof(MyClass), cudaMemcpyDeviceToHost); 然后获取数组本身。 cudaMemcpy(h_array, hc.array, Arra ...
  • 您可以使用条件编译标志__CUDA_ARCH__在__host__ __device__函数中为主机和设备生成不同的代码。 __CUDA_ARCH__仅为设备代码定义,因此要为主机和设备创建不同的实现,可以执行以下操作: __host__ __device__ double Vector::GetMagReciprocal() { double result; #ifdef __CUDA_ARCH__ result = rsqrt(x*x + y*y + z*z); #els ...
  • 是的,您可以创建任何类型的__device__ 。 它只是一个限定符,使该函数编译为在设备上运行并可从设备调用。 顺便说一下,CUDA有一个float3类型。 我从来没有使用它,但如果我float_3 ,它提供了与float_3相同的功能,并且还带有一个构造函数。 Yes, you can create __device__ of any type. It is just a qualifier that makes that function compile for running on the devi ...
  • 我认为这应该是可能的,因为他们有不同的范围。 这是你的错误。 他们没有不同的范围。 它们被标记为存在于不同的逻辑CUDA内存空间中,但这并不意味着C ++定义它的不同范围。 两者都是在同一个编译单元中编译并发布为符号,这就是编译器发出错误的原因。 I assume it should be possible since they have different scopes. That is your mistake. They do not have different scopes. They are t ...
  • 这大约是我可以对您的代码进行的“最小”更改,以使其大致按照您的意图运行。 另请注意,关于CUDA中的函数指针还有许多其他问题, 这个答案链接到几个。 用__host__ __device__装饰f1 。 这是使编译器为其生成设备可调用例程所必需的。 否则,仅生成主机代码。 我们需要捕获上面1中创建的设备可调用版本f1的设备入口地址。 有很多方法可以做到这一点。 我将使用另一个__device__变量( f1_d )“静态”捕获它,然后使用cudaMemcpyFromSymbol将其拉入主机代码。 您的gen ...
  • 这似乎是nvcc的限制,如其他地方已经指出的那样。 我已经向编译器团队提交了一个错误。 他们意识到了这个问题。 我没有关于可能的更新或时间表的任何进一步信息。 对于Linux / MacOS,建议如下可能的解决方法: #include template struct dummy { T inner; T __host__ __device__ get(void) { return inner; }; __host__ __device__ dumm ...
  • 在您的第一个相关链接中,我为基于对象的深层复制序列提供了5个步骤,但是这种情况很复杂,因为您正在执行该链接中给出的示例的双指针版本。 与双指针深拷贝相关的复杂性使得通常的建议是避免它 (即展平)。 我们需要对代码进行的第一个修复是正确处理d_par数组。 您需要在设备上进行相应的分配以保存与d_par关联的阵列。 与d_par关联的数组具有5个对象指针的存储空间。 你已经为它分配了主机端存储(使用new ),但是你无处为它进行设备端分配。 (我不是在讨论d_par指针本身 ,我在谈论它指向的是什么 ,这是一 ...
  • 符号引用GPU内存,因此当您要从设备复制到主机时,不能使用* ToSymbol。 对于要托管的设备,请使用cudaMemcpyFromSymbol 。 cudaError_t cudaMemcpyFromSymbol ( void * dst, const char * symbol, size_t count, size_t offset = 0, enum cudaMemcpyKind kind = cudaMemcpyDeviceToHost ) ...
  • 您可能需要阅读推力快速入门指南 。 这会让你遇到麻烦: thrust::host_vector Host_results; 这会创建一个零大小的矢量。 稍后当你这样做: thrust::device_vector Device_results = Host_results; 你已经创建了另一个零大小的向量。 虽然这些不会产生编译错误,但是如果你试图在没有适当大小分配的情况下使用这些错误(例如通过复制内容),你将在运行时遇到麻烦。 这也是错误的: Host_results = thru ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。