小编Nee*_*raj的帖子

Json将&在String中转换为\ u0026

我试图从pdf中提取文本并将其写入json文件.在提取unicode字符时,Json会将所有字符转换为\ u0026.例如我的实际字符串是&#1588.(代表ش).它正确打印到.txt文件,控制台等.但是当我尝试将此字符串打印到它显示的Json文件时\u0026#1588;.

我使用的是Java,代码是

Gson gson = new Gson();
String json = gson.toJson(pdfDoc);
Run Code Online (Sandbox Code Playgroud)

注意:pdfDoc是一个对象,它包含输入PDF文档中字符的所有细节(位置,颜色,字体等).我在用gson-2.2.1.jar.

java string unicode json gson

18
推荐指数
1
解决办法
3万
查看次数

String.replaceAll()不起作用

我正在编辑一些来自tesseract ocr的电子邮件.

这是我的代码:

 if (email != null) {
        email = email.replaceAll(" ", "");
        email = email.replaceAll("caneer", "career");
        email = email.replaceAll("canaer", "career");
        email = email.replaceAll("canear", "career");
        email = email.replaceAll("caraer", "career");
        email = email.replaceAll("carear", "career");
        email = email.replace("|", "l");
        email = email.replaceAll("}", "j");
        email = email.replaceAll("j3b", "job");
        email = email.replaceAll("gmaii.com", "gmail.com");
        email = email.replaceAll("hotmaii.com", "hotmail.com");
        email = email.replaceAll(".c0m", ".com");
        email = email.replaceAll(".coin", ".com");
        email = email.replaceAll("consuit", "consult");
    }
    return email;
Run Code Online (Sandbox Code Playgroud)

但输出不正确.

输入:

amrut=ac.hrworks@g mai|.com
Run Code Online (Sandbox Code Playgroud)

输出:

lalcl.lhlrlwlolrlklsl@lglmlalil|l.lclolml
Run Code Online (Sandbox Code Playgroud)

但是当我在每次替换后将结果分配给新的String时,它工作正常.为什么在同一个String中连续赋值不起作用?

java string str-replace

18
推荐指数
6
解决办法
5万
查看次数

正则表达式从字符串中查找电子邮件地址

我的目的是从网页上获取电子邮件地址.我有页面源代码.我正逐行阅读页面源代码.现在我想从我正在阅读的当前行获取电子邮件地址.此当前行可能有也可能没有电子邮件.我看到了很多正则表达式的例子.但其中大多数都是用于验证电子邮件地址.我想从页面源获取电子邮件地址而不是验证.它应该工作http://emailx.discoveryvip.com/正在工作

一些示例输入行是:

1)<p>Send details to <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;%72%65%62%65%6b%61%68@%68%61%63%6b%73%75%72%66%65%72.%63%6f%6d">neeraj@yopmail.com</a></p>

2)<p>Interested should send details directly to <a href="http://www.abcdef.com/abcdef/">www.abcdef.com/abcdef/</a>. Should you have any questions, please email <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6a%6f%62%73@%72%65%6c%61%79.%65%64%75">neeraj@yopmail.com</a>.

3)Note :- Send your queries at  neeraj@yopmail.com  for more details call Mr. neeraj 012345678901.
Run Code Online (Sandbox Code Playgroud)

我想从示例1,2和3中获取neeraj@yopmail.com.我正在使用java并且我在rexexp中表现不佳.帮我.

html java regex

14
推荐指数
2
解决办法
3万
查看次数

通过amazon ses发送HTML电子邮件

我正在使用亚马逊ses发送批量电子邮件.我的代码如下

public void sendMail(String sender, LinkedList<String> recipients, String subject, String body) {
    Destination destination = new Destination(recipients);
    try {
        ACCESS_KEY = EmailSender.prop.getProperty("accessKey");
        SECRET_KEY = EmailSender.prop.getProperty("secretKey");

        Content subjectContent = new Content(subject);
        Content bodyContent = new Content(body);
        Body msgBody = new Body(bodyContent);
        Message msg = new Message(subjectContent, msgBody);

        SendEmailRequest request = new SendEmailRequest(sender, destination, msg);

        AWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY);
        AmazonSimpleEmailServiceClient sesClient = new AmazonSimpleEmailServiceClient(credentials);
        SendEmailResult result = sesClient.sendEmail(request);

        System.out.println(result + "Email sent");  
    }catch(Exception e) {
        System.out.println("Exception from EmailSender.java. Email not …
Run Code Online (Sandbox Code Playgroud)

java amazon-web-services amazon-ses

10
推荐指数
1
解决办法
1万
查看次数

如何使用pdfbox获取字体颜色

我正在尝试使用pdfbox从pdf中提取所有信息的文本.除了颜色,我得到了我想要的所有信息.我尝试了不同的方法来获得fontcolor(包括使用PDFBox获取文本颜色).但不行.现在我从PageDrawer类的pdfBox中复制了代码.但是那时RGB值也不正确.

protected void processTextPosition(TextPosition text) {

        Composite com;
        Color col;
        switch(this.getGraphicsState().getTextState().getRenderingMode()) {
        case PDTextState.RENDERING_MODE_FILL_TEXT:
            com = this.getGraphicsState().getNonStrokeJavaComposite();
            int r =       this.getGraphicsState().getNonStrokingColor().getJavaColor().getRed();
            int g = this.getGraphicsState().getNonStrokingColor().getJavaColor().getGreen();
            int b = this.getGraphicsState().getNonStrokingColor().getJavaColor().getBlue();
            int rgb = this.getGraphicsState().getNonStrokingColor().getJavaColor().getRGB();
            float []cosp = this.getGraphicsState().getNonStrokingColor().getColorSpaceValue();
            PDColorSpace pd = this.getGraphicsState().getNonStrokingColor().getColorSpace();
            break;
        case PDTextState.RENDERING_MODE_STROKE_TEXT:
            System.out.println(this.getGraphicsState().getStrokeJavaComposite().toString());
            System.out.println(this.getGraphicsState().getStrokingColor().getJavaColor().getRGB());
           break;
        case PDTextState.RENDERING_MODE_NEITHER_FILL_NOR_STROKE_TEXT:
            //basic support for text rendering mode "invisible"
            Color nsc = this.getGraphicsState().getStrokingColor().getJavaColor();
            float[] components = {Color.black.getRed(),Color.black.getGreen(),Color.black.getBlue()};
            Color  c1 = new Color(nsc.getColorSpace(),components,0f);
            System.out.println(this.getGraphicsState().getStrokeJavaComposite().toString());
            break;
        default:
            System.out.println(this.getGraphicsState().getNonStrokeJavaComposite().toString());
            System.out.println(this.getGraphicsState().getNonStrokingColor().getJavaColor().getRGB());
    }
Run Code Online (Sandbox Code Playgroud)

我正在使用上面的代码.得到的值是R = 0,G …

java pdfbox

7
推荐指数
2
解决办法
9900
查看次数

用Java替换字符串中的所有"("和")"

如何用Java中的fullstop替换字符串中的所有"("和")"?我试着用以下方式:

String url = "https://bitbucket.org/neeraj_r/url-shortner)";
url.replaceAll(")", ".");
url.replaceAll(")", ".");
Run Code Online (Sandbox Code Playgroud)

但它不起作用.错误是:

Exception in thread "main" java.util.regex.PatternSyntaxException: Unmatched closing
')'
 )
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceAll(Unknown Source)
at com.azzist.cvConversion.server.URLChecker.main(URLChecker.java:32)
Run Code Online (Sandbox Code Playgroud)

我认为这个问题也存在于所有正则表达式中.\之前添加)不起作用.

java regex string replaceall

6
推荐指数
3
解决办法
3万
查看次数

如何使用java和PDFBox从PDF中获取字符的Unicode

我正在使用 Apache PDFBox 和 Java 来解析 PDF 并从中获取所有信息。提取文本仅适用于英语。对于其他语言,我只得到一些特殊字符。例如,提取阿拉伯字符 \xd8\xb4 将在打印时给出字符串 :"? 。当我将计算机的“区域和语言”从英语更改为阿拉伯语时,它工作正常。所以我认为提取字符的 Unicode将解决这个问题。请帮助我从 PDF 中获取字符的 Unicode 或建议我一些解决方案来解决这个问题。

\n

java pdf unicode pdfbox

5
推荐指数
1
解决办法
3760
查看次数

Regexp检查字符串中的连续3位数

如果字符串包含连续的3位数,我想在java中检查正则表达式.但问题是我的字符串可能包含unicode字符.如果字符串包含unicode字符,它应该跳过unicode字符(跳过4'.在&AND#之后)并且应该进行检查.一些例子是

Neeraj : false
Neeraj123 : true
&#1234Neeraj : false
&#1234Neeraj123 : true
123N&#123D : true
Neeraj&#1234 : false
Neeraj&#12DB123 : true
&#1234 : false
Run Code Online (Sandbox Code Playgroud)

java regex

4
推荐指数
1
解决办法
6210
查看次数

在opencv中创建透明图像

我正在尝试在 x、y 和 z 轴上旋转图像,如下所示。旋转时不应裁剪图像所以我正在这样做

Mat src = imread("path");
int diagonal = (int)sqrt(src.cols*src.cols+src.rows*src.rows);
int newWidth = diagonal;
int newHeight =diagonal;

Mat targetMat(newWidth, newHeight, src.type());
Run Code Online (Sandbox Code Playgroud)

我正在创建一个更大的图像 targetMat。输入图像是 png 图像。但我希望这个图像是透明图像。所以我尝试了这个

Mat targetMat(newWidth, newHeight, src.type(), cv::Scalar(0,0,0,0));

但输出图像是输出图像

我需要的是透明图像(透明图片在这里)

那么我需要做什么改变呢?

c++ opencv image-processing

2
推荐指数
1
解决办法
9765
查看次数

如何使用 opencv 将图像用作图案填充

我想用图像缩略图填充轮廓。区域轮廓将具有不同的形状。我需要将缩略图作为图案读取并用该图像填充轮廓。例如 在此处输入图片说明 在此处输入图片说明

我更喜欢使用 opencv 的解决方案。但任何程序化方法都是可观的。

c++ opencv image imagemagick image-processing

2
推荐指数
1
解决办法
1933
查看次数